-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdws-api-spec.yml
More file actions
5242 lines (5098 loc) · 187 KB
/
dws-api-spec.yml
File metadata and controls
5242 lines (5098 loc) · 187 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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
version: '1.10.0'
title: Nutrient DWS API reference
description: |
Nutrient Document Web Services API is an HTTP API that provides you with a simple document-in, document-out-based
workflow that scales as you grow. Generate PDFs, convert documents to PDF, modify existing PDFs, and more.
# Authorization
Nutrient DWS API uses an HTTP authorization header to map each request made to the
API to the user making the request. You're required to provide your API token in
the authorization header with each request you make. Otherwise, the API will return an error.
The authorization header has the following shape:
```
Authorization: Bearer <your_api_key_here>
```
`<your_api_key_here>` is an API key that can be retrieved
by logging in to the [dashboard](https://dashboard.nutrient.io/api/api_keys/).
Because this API allows full access to credits you purchased for Nutrient DWS API, it's
only meant to be used by your backend services, which we assume are fully trusted.
## JWT-based authorization
Apart from the API token, you can also use JWTs to authorize requests to DWS API. This is useful when you want finer control over authorization or if you want to interact with DWS API from a client-side application.
JWT authorization is a method of controlling access to resources through the use of JSON Web Tokens (JWTs). A [JWT](https://datatracker.ietf.org/doc/html/rfc7519) “is a compact, URL-safe means of representing claims to be transferred between two parties.”
It’s possible to generate a JWT using your API key via `POST tokens`[endpoint](https://www.nutrient.io/api/reference/public/#tag/JWT/operation/generate-token).
The JWT has a benefit of being able to customize the operations and origins the token can access. The token can be time-limited for the security of your application. It can also be revoked at any time, contrary to the API key, which can only be regenerated.
For example, you can generate a token that can only access the `pdfa_api` operation and can only be used from the `www.origin1` origin. In this way, the token may be shared with a third-party service that will only be able to access the `pdfa_api` operation from the `www.origin1` origin, without having access to other operations or origins.
Note that if the JWT has origin restrictions, the request must include the `Origin` header with the origin the token was generated for. If the `Origin` header isn’t provided, the request will be rejected. If origin restrictions aren’t set, the `Origin` header isn’t required.
It’s also possible to revoke a token using the `DELETE /tokens` [endpoint](https://www.nutrient.io/api/reference/public/#tag/JWT/operation/revoke-token).
contact:
name: Nutrient DWS API
url: https://www.nutrient.io/api/
license:
name: End User License Agreement
url: https://www.nutrient.io/api/terms/
servers:
- url: https://api.nutrient.io
description: Base URL for Nutrient DWS API endpoints.
security:
- BearerAuth: []
tags:
- name: Document editing
description: Process documents.
- name: Instant JSON
description: |
Instant JSON is a format we created for bringing annotations, forms and bookmarks into a modern format while keeping all important properties to make the Instant JSON spec work with PDF. The format is fully documented and can be easily converted to XFDF to make it interoperable.
Please refer to [Instant JSON Reference](https://www.nutrient.io/api/reference/document-engine/instant-json/) for full reference documentation of the format.
- name: Build API
description: |
Build API allows you to assemble a PDF from multiple parts, such as an existing PDF, a blank page, or an HTML page. You can apply one or more actions, such as watermarking, rotating pages, or importing annotations. Once the entire PDF is generated from its parts, you can also apply additional actions, such as optical character recognition (OCR), to the assembled PDF itself.
The Build API can be interacted with two distinct ways:
* The basic use case for the Build API is to upload all inputs together in the build instructions with the `multipart/form-data` request, where each input is provided as a separate part along with a special `instructions` part with the processing instructions.
* The Build API supports inputs provided from remote URLs. If all inputs are provided as remote URLs, the multipart request isn’t necessary and can be simplified to a non-multipart request with the `application/json` body with the processing instructions.
## Instructions Schema
When making requests to the API, the instructions object needs to follow the following schema:
<SchemaDefinition schemaRef="#/components/schemas/BuildInstructions" />
externalDocs:
description: Nutrient DWS API guides
url: https://www.nutrient.io/api/documentation/
paths:
/build:
post:
operationId: build-document
summary: Process documents and download the result
description: |
This endpoint lets you use [Build instructions](#tag/Build-API) to process a document. This allows you to
assemble a PDF from multiple parts, such as an existing document in a supported content type, a blank page,
or an HTML page. You can apply one or more actions, such as watermarking, rotating pages, or importing
annotations. Once the entire PDF is generated from its parts, you can also apply additional actions,
such as optical character recognition (OCR), to the assembled PDF itself.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BuildInstructions'
multipart/form-data:
schema:
type: object
properties:
instructions:
$ref: '#/components/schemas/BuildInstructions'
encoding:
instructions:
contentType: application/json
responses:
'200':
$ref: '#/components/responses/BuildResponseOk'
'400':
description: |
The request is malformed. Some invalid data was supplied, or a precondition wasn't met.
content:
application/json:
schema:
$ref: '#/components/schemas/HostedErrorResponse'
'401':
description: |
You are unauthorized. Sent when no API token is specified, or when the API token you specified isn't valid.
'402':
description: |
You have exceeded the total number of documents processed in your subscription.
'408':
description: |
The request timed out.
'413':
description: |
The request exceeds the maximum input size, meaning either a single part, or the sum of all parts, is large.
'422':
description: |
The request exceeds the maximum output file size.
'500':
description: |
An internal server error occurred. Please contact support.
tags:
- Document Editing
x-codeSamples:
- label: cURL
lang: curl
source: |
curl --request POST \
--url https://api.nutrient.io/build \
--header 'Authorization: Bearer <your_api_key_here>' \
--header 'content-type: application/json' \
--header 'pspdfkit-pdf-password: password' \
--data '{
"instructions": {
"parts": [{ "file": {"url": "https://remote-file-storage/input.pdf"}}],
"actions": [{ "type": "applyInstantJson", "file": {"url": "https://remote-file-storage/instant.json" }}],
"output": {
"metadata": {
"title": "Nutrient Document Engine API Specification",
"author": "Document Author"
},
"labels": [{ "pages": [0], "label": "Page I-III" }],
"user_password": "string",
"owner_password": "string",
"user_permissions": ["printing"],
"type": "pdf"
}
},
"document_id": "7KPSE41NWKDGK5T9CFS3S53JTP",
"title": "string",
"overwrite_existing_document": false
}'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.nutrient.io",
"port": null,
"path": "/build",
"headers": {
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
parts: [{file: 'pdf-file-from-multipart'}],
actions: [
{
type: 'applyInstantJson',
file: {url: 'https://remote-file-storage/input-file', sha256: 'string'}
}
],
output: {
metadata: {title: 'Nutrient Document Engine API Specification', author: 'Document Author'},
labels: [{pages: [[0]], label: 'Page I-III'}],
user_password: 'string',
owner_password: 'string',
user_permissions: ['printing'],
optimize: {
grayscaleText: false,
grayscaleGraphics: false,
grayscaleImages: false,
grayscaleFormFields: false,
grayscaleAnnotations: false,
disableImages: false,
mrcCompression: false,
imageOptimizationQuality: 2,
linearize: false
},
type: 'pdf'
}
}));
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}");
Request request = new Request.Builder()
.url("https://api.nutrient.io/build")
.post(body)
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
payload = "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}"
headers = {
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "application/json"
}
conn.request("POST", "/build", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
/analyze_build:
post:
summary: Analyze a build request
description: |
Performs analysis of the Build API request without actually executing it.
Use this endpoint to calculate how many credits a Build API request would consume. The request is free of charge.
Note: Make sure to provide the correct `content_type` parameter for each of your file parts to get accurate results.
Otherwise, the endpoint might not correctly identify conversion features such as Office or image conversion.
operationId: analyze_build
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BuildInstructions'
responses:
'200':
description: The analysis result.
content:
application/json:
schema:
$ref: '#/components/schemas/AnalyzeBuildResponse'
'400':
description: |
The request is malformed. Some invalid data was supplied, or a precondition wasn't met.
content:
application/json:
schema:
$ref: '#/components/schemas/HostedErrorResponse'
'401':
description: |
You are unauthorized. Sent when no API token is specified, or when the API token you specified isn't valid.
'408':
description: |
The request timed out.
'500':
description: |
An internal server error occurred. Please contact support.
tags:
- Document Editing
x-codeSamples:
- lang: curl
label: cURL
source: |-
curl --request POST \
--url https://api.nutrient.io/analyze_build \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"parts":[{"file":"pdf-file-from-multipart"}],"actions":[{"type":"applyInstantJson","file":{"url":"https://remote-file-storage/input-file","sha256":"string"}}],"output":{"metadata":{"title":"Nutrient Document Engine API Specification","author":"Document Author"},"labels":[{"pages":[[0]],"label":"Page I-III"}],"user_password":"string","owner_password":"string","user_permissions":["printing"],"optimize":{"grayscaleText":false,"grayscaleGraphics":false,"grayscaleImages":false,"grayscaleFormFields":false,"grayscaleAnnotations":false,"disableImages":false,"mrcCompression":false,"imageOptimizationQuality":2,"linearize":false},"type":"pdf"}}'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.nutrient.io",
"port": null,
"path": "/analyze_build",
"headers": {
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
parts: [{file: 'pdf-file-from-multipart'}],
actions: [
{
type: 'applyInstantJson',
file: {url: 'https://remote-file-storage/input-file', sha256: 'string'}
}
],
output: {
metadata: {title: 'Nutrient Document Engine API Specification', author: 'Document Author'},
labels: [{pages: [[0]], label: 'Page I-III'}],
user_password: 'string',
owner_password: 'string',
user_permissions: ['printing'],
optimize: {
grayscaleText: false,
grayscaleGraphics: false,
grayscaleImages: false,
grayscaleFormFields: false,
grayscaleAnnotations: false,
disableImages: false,
mrcCompression: false,
imageOptimizationQuality: 2,
linearize: false
},
type: 'pdf'
}
}));
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}");
Request request = new Request.Builder()
.url("https://api.nutrient.io/analyze_build")
.post(body)
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/analyze_build");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
payload = "{\"parts\":[{\"file\":\"pdf-file-from-multipart\"}],\"actions\":[{\"type\":\"applyInstantJson\",\"file\":{\"url\":\"https://remote-file-storage/input-file\",\"sha256\":\"string\"}}],\"output\":{\"metadata\":{\"title\":\"Nutrient Document Engine API Specification\",\"author\":\"Document Author\"},\"labels\":[{\"pages\":[[0]],\"label\":\"Page I-III\"}],\"user_password\":\"string\",\"owner_password\":\"string\",\"user_permissions\":[\"printing\"],\"optimize\":{\"grayscaleText\":false,\"grayscaleGraphics\":false,\"grayscaleImages\":false,\"grayscaleFormFields\":false,\"grayscaleAnnotations\":false,\"disableImages\":false,\"mrcCompression\":false,\"imageOptimizationQuality\":2,\"linearize\":false},\"type\":\"pdf\"}}"
headers = {
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "application/json"
}
conn.request("POST", "/analyze_build", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
/sign:
post:
summary: Digitally sign a PDF file
description: |
Use this endpoint to digitally sign a PDF file.
operationId: sign-file
parameters:
- $ref: '#/components/parameters/Password'
requestBody:
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
description: The binary content of a PDF file to be signed.
example: <PDF data>
data:
$ref: '#/components/schemas/CreateDigitalSignature'
description: |
Optional signing parameters. If omitted, defaults will be used:
- `signatureType`: `cms`
- `flatten`: `false`
- An invisible signature will be created
image:
type: string
format: binary
description: The watermark image to be used as part of the signature's appearance. Optional.
example: <Image data>
graphicImage:
type: string
format: binary
description: The graphic image to be used as part of the signature's appearance. Optional.
example: <Image data>
encoding:
file:
contentType: application/pdf
image:
contentType: application/pdf, image/jpg, image/png, image/tiff
graphicImage:
contentType: application/pdf, image/jpg, image/png, image/tiff
data:
contentType: application/json
responses:
'200':
description: The signed document.
content:
application/pdf:
schema:
type: string
description: The signed PDF file.
format: binary
example: <PDF file>
headers:
x-pspdfkit-request-cost:
$ref: '#/components/headers/x-pspdfkit-request-cost'
x-pspdfkit-remaining-credits:
$ref: '#/components/headers/x-pspdfkit-remaining-credits'
'400':
description: |
The request is malformed. Some invalid data was supplied, or a precondition wasn't met.
content:
application/json:
schema:
$ref: '#/components/schemas/HostedErrorResponse'
'401':
description: |
You are unauthorized. Sent when no API token is specified, or when the API token you specified isn't valid.
'402':
description: |
You have exceeded the total number of documents processed in your subscription.
'408':
description: |
The request timed out.
'413':
description: |
The request exceeds the maximum input size, meaning either a single part, or the sum of all parts, is large.
'422':
description: |
The request exceeds the maximum output file size.
'500':
description: |
An internal server error occurred. Please contact support.
tags:
- Digital Signatures
x-codeSamples:
- lang: curl
label: cURL
source: |-
curl --request POST \
--url https://api.nutrient.io/sign \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: multipart/form-data' \
--header 'pspdfkit-pdf-password: password' \
--form 'file=<PDF data>' \
--form 'data={"signatureType":"cades","flatten":false,"appearance":{"mode":"signatureOnly","contentType":"image/png","showWatermark":true,"showSignDate":true},"position":{"pageIndex":0},"cadesLevel":"b-lt"}' \
--form 'image=<Image data>' \
--form 'graphicImage=<Image data>'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.nutrient.io",
"port": null,
"path": "/sign",
"headers": {
"pspdfkit-pdf-password": "password",
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "multipart/form-data"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<PDF data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"signatureType\":\"cades\",\"flatten\":false,\"appearance\":{\"mode\":\"signatureOnly\",\"contentType\":\"image/png\",\"showWatermark\":true,\"showSignDate\":true},\"position\":{\"pageIndex\":0},\"cadesLevel\":\"b-lt\"}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\n<Image data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"graphicImage\"\r\n\r\n<Image data>\r\n-----011000010111000001101001--\r\n");
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<PDF data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"signatureType\":\"cades\",\"flatten\":false,\"appearance\":{\"mode\":\"signatureOnly\",\"contentType\":\"image/png\",\"showWatermark\":true,\"showSignDate\":true},\"position\":{\"pageIndex\":0},\"cadesLevel\":\"b-lt\"}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\n<Image data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"graphicImage\"\r\n\r\n<Image data>\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("https://api.nutrient.io/sign")
.post(body)
.addHeader("pspdfkit-pdf-password", "password")
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.addHeader("content-type", "multipart/form-data")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/sign");
var request = new RestRequest(Method.POST);
request.AddHeader("pspdfkit-pdf-password", "password");
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "multipart/form-data");
request.AddParameter("multipart/form-data", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<PDF data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"signatureType\":\"cades\",\"flatten\":false,\"appearance\":{\"mode\":\"signatureOnly\",\"contentType\":\"image/png\",\"showWatermark\":true,\"showSignDate\":true},\"position\":{\"pageIndex\":0},\"cadesLevel\":\"b-lt\"}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\n<Image data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"graphicImage\"\r\n\r\n<Image data>\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n<PDF data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"signatureType\":\"cades\",\"flatten\":false,\"appearance\":{\"mode\":\"signatureOnly\",\"contentType\":\"image/png\",\"showWatermark\":true,\"showSignDate\":true},\"position\":{\"pageIndex\":0},\"cadesLevel\":\"b-lt\"}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\n<Image data>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"graphicImage\"\r\n\r\n<Image data>\r\n-----011000010111000001101001--\r\n"
headers = {
'pspdfkit-pdf-password': "password",
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "multipart/form-data"
}
conn.request("POST", "/sign", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
/tokens:
post:
operationId: generate-token
summary: Generate a new API token
description: |
Use this endpoint to generate a new API token. All request body parameters are optional.
tags:
- JWT
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAuthTokenParameters'
responses:
'201':
description: The generated API token.
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAuthTokenResponse'
'400':
description: |
The request is malformed. Some invalid data was supplied, or a precondition wasn't met.
content:
application/json:
schema:
type: object
properties:
status:
type: integer
example: 400
errors:
type: array
items:
type: object
properties:
allowedOperations:
type: string
example: Description of error
allowedOrigins:
type: string
example: Description of error
expirationTime:
type: string
example: Description of error
x-codeSamples:
- lang: curl
label: cURL
source: |-
curl --request POST \
--url https://api.nutrient.io/tokens \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"allowedOperations":["digital_signatures_api"],"allowedOrigins":["example.com"],"expirationTime":3600}'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "POST",
"hostname": "api.nutrient.io",
"port": null,
"path": "/tokens",
"headers": {
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
allowedOperations: ['digital_signatures_api'],
allowedOrigins: ['example.com'],
expirationTime: 3600
}));
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"allowedOperations\":[\"digital_signatures_api\"],\"allowedOrigins\":[\"example.com\"],\"expirationTime\":3600}");
Request request = new Request.Builder()
.url("https://api.nutrient.io/tokens")
.post(body)
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/tokens");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"allowedOperations\":[\"digital_signatures_api\"],\"allowedOrigins\":[\"example.com\"],\"expirationTime\":3600}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
payload = "{\"allowedOperations\":[\"digital_signatures_api\"],\"allowedOrigins\":[\"example.com\"],\"expirationTime\":3600}"
headers = {
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "application/json"
}
conn.request("POST", "/tokens", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
delete:
operationId: revoke-token
summary: Revoke an API token
description: |
Use this endpoint to revoke an API token.
tags:
- JWT
requestBody:
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: The ID of the token to revoke.
example: FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8
responses:
'204':
description: The token was successfully revoked.
'404':
description: The token was not found.
x-codeSamples:
- lang: curl
label: cURL
source: |-
curl --request DELETE \
--url https://api.nutrient.io/tokens \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"id":"FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8"}'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "DELETE",
"hostname": "api.nutrient.io",
"port": null,
"path": "/tokens",
"headers": {
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "application/json"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({id: 'FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8'}));
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"id\":\"FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8\"}");
Request request = new Request.Builder()
.url("https://api.nutrient.io/tokens")
.delete(body)
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/tokens");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"id\":\"FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
payload = "{\"id\":\"FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8\"}"
headers = {
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "application/json"
}
conn.request("DELETE", "/tokens", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
/account/info:
get:
summary: Get account information
description: |
Use this endpoint to get information about your account, such as the number of credits you have left.
operationId: get-account-info
responses:
'200':
description: Account information.
content:
application/json:
schema:
type: object
properties:
apiKeys:
type: object
description: Information about your API keys.
properties:
live:
type: string
description: Your live API key.
signedIn:
type: boolean
description: Whether you are signed in.
example: true
subscriptionType:
enum:
- free
- paid
- enterprise
description: Your subscription type.
usage:
type: object
description: Information about your usage.
properties:
totalCredits:
type: number
description: The number of credits available in the current billing period.
example: 100
usedCredits:
type: number
description: The number of credits you have used in the current billing period.
example: 50
'401':
description: |
You are unauthorized. Sent when no API token is specified, or when the API token you specified isn't valid.
tags:
- Account
x-codeSamples:
- lang: curl
label: cURL
source: |-
curl --request GET \
--url https://api.nutrient.io/account/info \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN'
- lang: JavaScript
label: Node.js
source: |-
const http = require("https");
const options = {
"method": "GET",
"hostname": "api.nutrient.io",
"port": null,
"path": "/account/info",
"headers": {
"Authorization": "Bearer REPLACE_BEARER_TOKEN"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
- lang: Java
label: Java
source: |-
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.nutrient.io/account/info")
.get()
.addHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.build();
Response response = client.newCall(request).execute();
- lang: C#
label: C#
source: |-
var client = new RestClient("https://api.nutrient.io/account/info");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
IRestResponse response = client.Execute(request);
- lang: Python
label: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.nutrient.io")
headers = { 'Authorization': "Bearer REPLACE_BEARER_TOKEN" }
conn.request("GET", "/account/info", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
/ai/redact:
post:
summary: Redact sensitive information from a document
operationId: ai-redact
description: |
Redacts sensitive information from a document based on the provided criteria.
requestBody:
content:
multipart/form-data:
schema:
type: object
required:
- data
- file
properties:
data:
description: |
Parameters required for the redaction.
$ref: '#/components/schemas/RedactData'
file:
type: string
format: binary
description: The PDF file to process.
example: <PDF data>
encoding:
data:
contentType: application/json
file:
contentType: application/pdf
application/json:
schema:
$ref: '#/components/schemas/RedactData'
responses:
'200':
description: The redacted document
content:
application/pdf:
schema:
type: string
format: binary
description: The redacted PDF file
headers:
x-pspdfkit-request-cost:
schema:
type: number
description: Cost of the request in credits
x-pspdfkit-remaining-credits: