-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarboneio-api-spec.yaml
More file actions
427 lines (414 loc) · 16.7 KB
/
carboneio-api-spec.yaml
File metadata and controls
427 lines (414 loc) · 16.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
openapi: 3.0.3
info:
description: |-
Carbone Cloud/On-premise Open API reference.
This API is used by the aam-services backend internally, exposing its functionality through our own, auth protected endpoints.
For requesting:
- Carbone Cloud API: find your API key on your [Carbone account](https://account.carbone.io). Home page > Copy the `production` or `testing` API key.
- Carbone On-premise: Update the `Server URL` on the Open API specification.
Useful links:
- [API Flow](https://carbone.io/api-reference.html#quickstart-api-flow)
- [Integration / SDKs](https://carbone.io/api-reference.html#api-integration)
- [Generated document storage](https://carbone.io/api-reference.html#report-storage)
- [Request timeout](https://carbone.io/api-reference.html#api-timeout)
version: "1.2.0"
title: "Carbone API"
contact:
name: "Carbone Support"
email: "support@carbone.io"
url: "https://help.carbone.io"
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: https://api.carbone.io
description: Production server
tags:
- name: "template"
description: "Manage templates"
- name: "render"
description: "Manage renders"
- name: "status"
description: "API Status"
paths:
/template:
post:
tags:
- "template"
summary: "Upload a template."
description: "Documentation: https://carbone.io/api-reference.html#add-templates"
security:
- bearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/carboneVersion'
requestBody:
required: true
description: "Template File to upload, supported formats: DOCX, XLSX, PPTX, ODT, ODS, ODP, ODG, XHTML, IDML, HTML or an XML file"
content:
multipart/form-data:
schema:
type: object
required:
- "template"
properties:
template:
type: string
format: binary
application/json:
schema:
type: object
required:
- "template"
properties:
template:
type: string
example: "base64-encoded file contents"
responses:
'200': # status code
description: On success, the `template ID` is returned.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
data:
type: object
properties:
templateId:
type: string
'400':
$ref: '#/components/responses/NotFileError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'415':
$ref: '#/components/responses/TemplateFormatError'
'422':
$ref: '#/components/responses/MissingTemplateFieldError'
/template/{templateId}:
get:
description: "Documentation: https://carbone.io/api-reference.html#get-templates"
tags:
- "template"
summary: "Download a template from a template ID"
security:
- bearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/templateId'
- $ref: '#/components/parameters/carboneVersion'
responses:
'200':
description: "stream of the file content"
headers:
content-disposition:
schema:
type: string
description: "Template name, for instance: 'filename=\"{templateid}.docx\"'."
content-type:
schema:
type: string
description: "File type"
'400':
$ref: '#/components/responses/templateIdNotValidError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/TemplateNotFoundError'
delete:
description: "Documentation: https://carbone.io/api-reference.html#delete-templates"
tags:
- "template"
summary: "Delete a template from a template ID"
security:
- bearerAuth: [ ]
parameters:
- $ref: '#/components/parameters/templateId'
- $ref: '#/components/parameters/carboneVersion'
responses:
'200':
description: "The template is deleted"
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: true
'400':
$ref: '#/components/responses/templateIdNotValidError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/TemplateNotFoundError'
/render/{templateId}:
post:
summary: "Generate a document from a template ID, and a JSON data-set"
description: "Documentation: https://carbone.io/api-reference.html#render-reports"
security:
- bearerAuth: [ ]
tags:
- "render"
parameters:
- $ref: '#/components/parameters/templateId'
- $ref: '#/components/parameters/carboneVersion'
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
type: object
example: { "id": "42", "name": "John", "type": "invoice" }
description: "Required - JSON data-set merged into the template to generate a document"
convertTo:
type: string
example: "pdf"
description: "Optional - Convert the document into another format. Accepted values: ods xlsx xls csv pdf txt odp ppt pptx jpg png odt doc docx txt jpg png epub html xml idml. List of supported formats: https://carbone.io/documentation.html#supported-files-and-features-list"
timezone:
type: string
example: "Europe/Paris"
description: "Optional - Convert document dates to a timezone. The default timezone is `Europe/Paris`. The date must be chained with the `:formatD` formatter, for instance `{d.date:formatD(YYYY-MM-DD HH:MM)}`. List of accepted timezones (Column TZ identifier): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"
lang:
type: string
example: "fr-fr"
description: "Optional - Locale of the generated doocument, it will used for translation `{t()}`, formatting numbers with `:formatN`, and currencies `:formatC`. List of supported locales: https://github.com/carboneio/carbone/blob/master/formatters/_locale.js"
complement:
type: object
example: { }
description: "Optional - Object|Array, extra data accessible in the template with {c.} instead of {d.}"
variableStr:
type: string
example: "{#def = d.id}"
description: "Optional - Predefine alias, related documenation: https://carbone.io/documentation.html#alias"
reportName:
type: string
example: "{d.date}.odt"
description: "Optional - Static or dynamic file name returned on the `content-disposition` header when the generated report is fetched with `GET /report/:renderI`. Multiple Carbone tags are accepted, such as `{d.type}-{d.date}.pdf`"
enum:
type: object
example: { }
description: "Optional - List of enumerations, use it in reports with `convEnum` formatters, documentation: https://carbone.io/documentation.html#convenum-type-"
translations:
type: object
example: { "fr": { "one": "un" }, "es": { "one": "uno" } }
description: "Optional - When the report is generated, all text between `{t( )}` is replaced with the corresponding translation. The `lang` option is required to select the correct translation. Learn more: https://carbone.io/documentation.html#translations"
currencySource:
type: string
example: "EUR"
description: "Optional - Currency source coming from your JSON data. The option is used by `formatC` to convert the currency based on the `currencyTarget` and `currencyRates`. Learn more: https://carbone.io/documentation.html#formatc-precisionorformat-"
currencyTarget:
type: string
example: "USD"
description: "Optional - Target currency when the document is generated. The option is used by `formatC` to convert the currency based on the `currencySource` and `currencyRates`. Learn more: https://carbone.io/documentation.html#formatc-precisionorformat-"
currencyRates:
type: object
example: { "EUR": 1, "USD": 1.2 }
description: "Optional - Currency exchange rates for conversions from `currencySource` to `currencyTarget`. Learn more: https://carbone.io/documentation.html#formatc-precisionorformat-"
hardRefresh:
type: boolean
example: false
description: "Optional - If true, the report content is refreshed at the end of the rendering process. To use this option, `convertTo` has to be defined. It is mostly used to refresh a table of content."
responses:
"200":
description: "On success, a `render ID` is returned, a unique identifier for the generated document."
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: true
data:
type: object
properties:
renderId:
type: string
'400':
$ref: '#/components/responses/NotJsonError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/TemplateNotFoundError'
'422':
$ref: '#/components/responses/MissingDataFieldError'
'500':
$ref: '#/components/responses/GenerateReportError'
/render/{renderId}:
get:
summary: "Retreive a generated document from a render ID."
description: "Documentation: https://carbone.io/api-reference.html#download-rendered-reports"
tags:
- "render"
parameters:
- $ref: '#/components/parameters/renderId'
- $ref: '#/components/parameters/carboneVersion'
responses:
'200':
description: "Stream of the generated document"
headers:
content-disposition:
schema:
type: string
description: "File name, for instance: 'filename=\"report.pdf\"'. The default value is 'report'. The file name can be changed dynamically thanks to the `reportName` option when generating a document with `POST /render/:templateId`."
content-type:
schema:
type: string
description: "File type"
'400':
$ref: '#/components/responses/RenderIdNotValidError'
'401':
$ref: '#/components/responses/UnauthorizedError'
'404':
$ref: '#/components/responses/FileDoesNotExistError'
/status:
get:
tags:
- "status"
summary: "Fetch the API status and version"
responses:
'200':
description: "Check the API status and version"
content:
application/json:
schema:
type: object
example: { "success": true, "code": 200, "message": "OK", "version": "4.13.0" }
properties:
success:
type: boolean
code:
type: number
message:
type: string
version:
type: string
'500':
description: "Something went wrong, contact support on the chat"
components:
securitySchemes:
bearerAuth: # arbitrary name for the security scheme
type: http
description: "Get you test or production API Key on https://account.carbone.io"
scheme: bearer
bearerFormat: "eyJhbGci..."
parameters:
carboneVersion:
name: "carbone-version"
description: "Carbone version"
in: "header"
required: true
schema:
type: integer
format: int32
default: 4
templateId:
in: path
name: "templateId"
description: "Unique identifier of the template"
schema:
type: string
required: true
renderId:
in: path
name: "renderId"
description: "Unique identifier of the report"
schema:
type: string
required: true
responses:
CResponseError:
description: Error response when the request is invalid.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
default: false
data:
type: object
UnauthorizedError:
description: "Unauthorized, please provide a correct API key on the `Authorization ` header. The API key is available on your Carbone account: https://account.carbone.io"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Unauthorized, please provide a valid API key on the 'Authorization' header" }
NotJsonError:
description: "The body request type is not correct, it must be a JSON type and the `Content-type` header must be `application/json`"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "'Content-Type' header is not 'application/json'" }
TemplateNotFoundError:
description: "The template is not found"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Template not found" }
MissingDataFieldError:
description: "The 'data' property is missing on the body request."
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Missing 'data' property in body" }
GenerateReportError:
description: "Something went wrong when merging the JSON data-set into the template. The design of the template has an issue."
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Error while rendering template" }
NotFileError:
description: "The body request type is not correct, it must be a FormData or a JSON. The `Content-type` header must be either `application/json` or `multipart/form-data`"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Content-Type header should be multipart/form-data or application/json" }
TemplateFormatError:
description: "Template format not supported, it must be an XML-based document: DOCX, XLSX, PPTX, ODT, ODS, ODP, ODG, XHTML, IDML, HTML or an XML file"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Template format not supported" }
MissingTemplateFieldError:
description: "The `template` field is empty on the body request"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "'template' field is empty" }
templateIdNotValidError:
description: "The `template ID` is not valid"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Invalid templateId" }
FileDoesNotExistError:
description: "The file does not exist."
content:
application/json:
schema:
type: object
example: { "success": false, "error": "File not found" }
RenderIdNotValidError:
description: "The `render ID` is not valid"
content:
application/json:
schema:
type: object
example: { "success": false, "error": "Invalid render ID" }