Skip to content

Commit 54ca3bf

Browse files
committed
Update to version 4.0.0 on 2026-10-26
- **BREAKING CHANGE**: This version calls DocSpring API v2 (`/api/v2`). The 3.x versions call API v1, which keeps working. Every change is in the migration guide: https://docspring.com/docs/api-guide/migrating-to-api-v2/ - **BREAKING CHANGE**: If you set the API's full base URL yourself, change `/api/v1` in it to `/api/v2`. The client only picks the version in the URLs it builds from a region or host. - **BREAKING CHANGE**: Operations are named after the resource they act on. generate_pdf is create_submission, batch_generate_pdfs is create_submission_batch, combine_pdfs is create_combined_pdf, create_html_template and create_pdf_template_from_upload are create_template (with a `template_type`), create_pdf_template (which uploads a PDF file) is upload_template, get_full_template is get_template (which returns the template, without its fields for now), update_template_document (which uploads a PDF file) is upload_template_document, update_template_document_from_upload is update_template_document, generate_preview is generate_submission_preview, get_combined_submission is get_combined_pdf, list_combined_submissions is list_combined_pdfs, expire_combined_submission is expire_combined_pdf, move_template_to_folder is move_template and move_folder_to_folder is move_folder. New: get_folder, list_custom_files, get_custom_file and delete_custom_file. A template's fields, and adding fields to a template, aren't in API v2 yet. - **BREAKING CHANGE**: Data requests are called signature requests. `get_data_request`, `update_data_request`, `create_data_request_token` and `create_data_request_event` are `get_signature_request`, `update_signature_request`, `create_signature_request_token` and `create_signature_request_event` (at `/signature_requests`), and their models are `SignatureRequest`, `SignatureRequestToken` and `SignatureRequestEvent`. A submission's `data_requests` is `signature_requests` (also when you create one), `data_request_id` is `signature_request_id`, a token's `data_request_url` is `signature_request_url`, the `waiting_for_data_requests` state is `waiting_for_signature_requests`, and a template's `add_data_request_submission_id_footers` is `add_signature_request_submission_id_footers`. New ones get IDs that start with `srq_` instead of `drq_`. - **BREAKING CHANGE**: A response is the resource itself, with no `status` or wrapper key. Lists return `data` and `next_cursor`: pass `next_cursor` as `cursor` to get the next page, and `limit` (1 to 100, default 50) for its size. `page` and `per_page` are gone. Every create returns 201. - **BREAKING CHANGE**: Every error has one shape, `{"error": {"code", "message", "details", "request_id"}}`, with a `code` to check (`validation_failed`, `not_found`, `insufficient_credits`, `rate_limited`, ...), and each detail has a `pointer` to the body value it's about, or a `parameter` with the query parameter's name. - **BREAKING CHANGE**: Requests are validated strictly: an unknown property or query parameter, or a value of the wrong type, is a 422 instead of being ignored. Request bodies must be JSON (`Content-Type: application/json`, or it's a 415), except the PDF uploads. Request bodies are flat, with no `template`, `folder` or `webhook` key around them. - **BREAKING CHANGE**: Submission data is checked more strictly. An empty `data` is validated like any other, date fields take `YYYY-MM-DD` (or the template's date format when `parse_dates_using_template_date_format` is on), and a signature request's `fields` must be fields on the template (set `ignore_unknown_fields` to leave out the others). A submission that fails because of the template is still saved as `invalid_data`, and the 422 includes its `submission_id`. - **BREAKING CHANGE**: A submission's or combined PDF's files are in `files`, by format. `files.pdf` has `state`, `error_message`, `download_url`, `permanent_url`, `filename`, `content_type`, `size` and `sha256`, and replaces `download_url`, `permanent_download_url` and `pdf_hash`. A submission's `files.audit_trail` and `files.preview`, with the same properties, replace `audit_trail_download_url` and `preview_download_url`. A file made after its submission was processed is listed while it's being made, so check its `state` before using its links. Combined submissions are combined PDFs (`CombinedPdf`), a template's `document_url` is `document.download_url`, and a custom file's `url` is `download_url`. - **BREAKING CHANGE**: A template's `embed_domains` is a list of domains, not a comma-separated string, and each entry is checked. Copying a template with `parent_folder_id` null puts the copy at the root (leave it out to keep the template's folder). A template's schema and model code describe the version that submissions use by default (the latest published version), not the draft: pass `version` for another one. - **BREAKING CHANGE**: Every property name is snake_case, including template `defaults` (`font_size`, was `fontSize`), `html_engine_options` (`margin_top`), a field dependency condition's `range_max`, and the field settings in a submission's `field_overrides`. - **BREAKING CHANGE**: `field_overrides` takes a `FieldOverride` per field name (`Map<String, FieldOverride>`), with every setting an override can change (`required`, `font_size`, `color`, ...), so a misspelt setting or a value of the wrong type is caught before the request is sent. - **BREAKING CHANGE**: A combined PDF's `source_pdfs` and a rule's `conditions` take a model per kind, with only the properties that kind uses (another kind's property is a 422 `not_allowed`). `CombinedPdfSourceInput` is a `SubmissionSourcePdf`, `CombinedPdfSourcePdf`, `TemplateSourcePdf`, `CustomFileSourcePdf` or `UrlSourcePdf`, picked by its `type`. `TemplateFieldDependencyConditionInput` is a `FieldPresenceCondition` (`present`, `blank`), `FieldEqualsCondition` (`equals`, `not_equals`), `FieldInCondition` (`in`, with a list), `FieldComparisonCondition` (`gt`, `gte`, `lt`, `lte`, on a number field) or `FieldRangeCondition` (`range`), picked by its `operator`. Pass the model to the union's constructor; a model sets its own `type` (and `FieldInCondition` and `FieldRangeCondition` their `operator`): `new CombinedPdfSourceInput(new UrlSourcePdf().url(url))`. A template returns its conditions with only the properties their operators use, in the shape an update takes. - **BREAKING CHANGE**: Templates: `ready` and a `document` object (with its `state`, `page_count` and `page_dimensions`) replace `document_processed`, `document_state`, `document_parse_error` and the `page_*` fields. `list_templates` returns template summaries. Templates have no `webhook_url` or `webhook_options`: create a webhook with `template_ids` instead. - **BREAKING CHANGE**: Secrets are write-only. A submission's or combined PDF's `password` and a template's `encrypt_pdfs_password` and `slack_webhook_url` aren't returned; `has_password`, `has_encrypt_pdfs_password` and `has_slack_webhook_url` say whether one is set. - **BREAKING CHANGE**: Webhooks created with this version send payload version 4, `{"id", "event_type", "created_at", "data"}`, where `data` is the resource as API v2 returns it. Their events have API v2's names (`combined_pdf.processed`, `signature_request.completed`). Webhooks created with 3.x or in the dashboard keep their payload version. - **BREAKING CHANGE**: Models are named after the API's resources (`Submission`, `CombinedPdf`, `Template`, `TemplateSummary`, `SignatureRequest`), request bodies after their operation (`CreateSubmissionRequest`), and enums are their own types (`SubmissionState`, `WebhookEventType`). - **BREAKING CHANGE**: Enum types are final classes instead of Java `enum`s, so they can hold a value added to the API after this release. The constants (`SubmissionState.PROCESSED`) are the values this version knows, `getValue()` returns the value as the API sent it, `isKnown()` is false for a newer one, `fromValue` keeps any value, `values()` lists the known ones, and equality is by value. A `switch` on one needs `getValue()`. `UNKNOWN_DEFAULT_OPEN_API` is gone. - The client checks each request against the API's request schemas before sending it, so an invalid request fails without a round trip, with the details the API's 422 response would have. A request the API would reject throws a `com.docspring.ValidationException` (an `IllegalArgumentException`), whose `getDetails()` are `ErrorDetail`s with a code, a message and a pointer into the body (or a parameter). Turn the check off with `apiClient.setValidateRequests(false)`. - A waited request to `sync.api.docspring.com` that times out returns a 504 `polling_timeout` error with the resource's ID, so you can get it later. Without an ID, the request got no answer in time: check whether the resource was created before you send it again. - Lists you don't set are left out of requests instead of being sent as empty lists. - **BREAKING CHANGE**: URLs are `String`s instead of `java.net.URI`, which couldn't hold every URL the API returns. Free-form objects (`data`, `metadata`) are `Map<String, Object>`, and lists of unique values are `Set`s. - Depends on Jackson 2.21 (was 2.17) and jackson-databind-nullable 0.2.12. - An empty API token ID or secret counts as not set, so the client reads `DOCSPRING_TOKEN_ID` or `DOCSPRING_TOKEN_SECRET` instead. It was sent as an empty string. - Templates: new `default_form_mode` setting (`web`, `visual` or `dual`), when you create or update a template. It's the hosted form that `/templates/<id>/form` opens when the link has no `mode` parameter: the web form, the visual form (filled in on the PDF), or both in tabs. HTML templates have no visual form, so they only accept `web`. - Templates: `defaults` can set `required_field_background_color`, the background colour that visual forms and signature requests give required fields. PDFs don't draw it. - Templates: new `allow_skipping_optional_fields` setting (boolean), when you create or update a template. Visual forms and signature requests then show the Continue button as soon as the required fields are filled in, without visiting each optional field. The `allowSkippingOptionalFields` embed option overrides it. - Templates: when you replace a template's PDF, `reimport_fields` (boolean) replaces the template's fields with the fillable fields in the new PDF (or in its current PDF when you don't upload one). A PDF with no fillable fields keeps the template's fields. - Fields: `shape_type` can be `triangle` or `polygon`, with `shape_sides` (3 to 12) for a polygon. Text fields can set `keep_leading_spaces` to keep the spaces at the start of each line in the PDF. - Templates: create_template and upload_template take `detect_fields` (boolean, default false). DocSpring then sets up the PDF's fields as the "Automatically detect fields" upload option does: it imports or detects them, names them with AI and sets up conditional logic. `field_source` (`auto`, `pdf_detection` or `pdf_form_fields`), `field_naming` (`ai` or `preserve`) and `field_logic` (`ai` or `none`) choose how, like the Set Up Fields choices in the template editor. With `pdf_form_fields`, `preserve` and `none`, the PDF's form fields are imported with their own names and no AI. Each account gets free AI pages every month, and further pages are paid from credits. See https://docspring.com/docs/template-editor/automatic-field-detection/. - Templates: new `ai_field_naming_language` setting (`auto`, `english` or `form_language`) for PDF templates, when you create or update one: the language AI uses for field names. It's null for HTML templates. - Templates: a template's `document` includes `has_fillable_fields`, `page_processing_statuses` (how processing is going on each page: its image, its fields and AI naming) and `field_logic_status` (the AI logic step that runs once every page's fields are done, and can still rename fields and add rules). Field setup is finished when `document.state` is `processed` and `field_logic_status` isn't `pending` or `processing`. - Java: `createPdfTemplate` (multipart) takes the new `detect_fields`, `field_source`, `field_naming`, `field_logic` and `ai_field_naming_language` form fields as its last five arguments, so existing calls need five more arguments (`null` to leave them out).
1 parent 1b88e6d commit 54ca3bf

521 files changed

Lines changed: 58457 additions & 31184 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.openapi-generator/FILES‎

Lines changed: 360 additions & 150 deletions
Large diffs are not rendered by default.

‎.openapi-generator/VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.16.0-DOCSPRING
1+
7.26.0-DOCSPRING

‎AGENTS.md‎

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,93 @@
11
# AGENTS.md
22

3-
Notes for AI coding agents working with the DocSpring Java SDK (`com.docspring:DocSpring`), in this repository or
4-
as a dependency of an app.
3+
Notes for AI coding agents working with the DocSpring Java SDK (`com.docspring:DocSpring`): integrating it into an
4+
app, or working in this repository.
55

66
## This code is generated
77

88
Every file here is generated from DocSpring's OpenAPI spec by
99
[DocSpring's fork of OpenAPI Generator](https://github.com/DocSpring/openapi-generator/tree/docspring/all_patches), and each release replaces
10-
all of it. Don't edit it or open pull requests that change it, and don't patch an installed copy: the next release
11-
overwrites the change. Report bugs at https://github.com/DocSpring/docspring-java/issues or to support@docspring.com, and DocSpring fixes them in
12-
the generator.
10+
all of it. Don't patch an installed copy: the next release overwrites the change. Issues and pull requests are welcome
11+
at https://github.com/DocSpring/docspring-java (or email support@docspring.com), and DocSpring makes the fix in the generator so that every release
12+
keeps it.
1313

1414
## Where to look
1515

1616
- [README.md](README.md): install, configuration, an example and how errors and API changes are handled.
1717
- [docs/Client.md](https://github.com/DocSpring/docspring-java/blob/main/docs/Client.md): every method, with its parameters and return type.
1818
- [docs/](https://github.com/DocSpring/docspring-java/tree/main/docs): every model and its fields.
1919
- https://docspring.com/docs/llms.txt: DocSpring's documentation for LLMs (`llms-small.txt`, `llms-full.txt`).
20-
- https://docspring.com/docs/api/: the API reference, with Java code for every method.
21-
- https://docspring.com/api-docs/v1/openapi.json: the OpenAPI spec this SDK is generated from.
22-
23-
## Using it in an app
24-
25-
- Credentials come from `DOCSPRING_TOKEN_ID` and `DOCSPRING_TOKEN_SECRET`. Keep them in the environment or a secret
26-
store, never in code. Accounts in the EU region also need `DOCSPRING_REGION=EU`.
27-
- Template IDs look like `tpl_...` and submission IDs like `sub_...`.
28-
- Pass `test: true` when you generate PDFs during development: test PDFs are free and watermarked.
29-
- Generating a PDF waits for it, for up to 95 seconds. For many PDFs or slow templates, set `wait` to false and use
30-
webhooks or check the submission later (https://docspring.com/docs/api-guide/synchronous-requests/).
31-
- Errors: Methods throw `com.docspring.ApiException` for an error response, with the HTTP status in `getCode()` and the body in `getResponseBody()`.
32-
- Responses can be newer than this SDK, because DocSpring adds fields and enum values to API v1 without a new
33-
version. The model keeps a response field added to the API after this release in its additional properties (`getAdditionalProperties()`). An enum value added to the API after this release comes back as `UNKNOWN_DEFAULT_OPEN_API`, so give each `switch` over an enum a case or default for it.
20+
- https://docspring.com/docs/: the guides. https://docspring.com/docs/api/: the API reference, with Java code
21+
for every method.
22+
- https://docspring.com/api-docs/v2/openapi.json: the OpenAPI spec this SDK is generated from.
23+
24+
## Set up
25+
26+
- Credentials come from `DOCSPRING_TOKEN_ID` and `DOCSPRING_TOKEN_SECRET` (an API token from
27+
https://app.docspring.com/api_tokens). Keep them in the environment or a secret store, never in code. An account in
28+
the EU region also needs `DOCSPRING_REGION=EU`.
29+
- Call DocSpring from your server. The token secret gives full access to the account, so it must never reach a browser
30+
or a mobile app. Signers use signing links or the embedded signing form instead (see Signature requests).
31+
- `testAuthentication` checks the credentials.
32+
33+
## Generate PDFs
34+
35+
- Read a template's data shape before writing the request: `getTemplateSchema` returns the
36+
JSON Schema of its submission data (its field names and types), and `getTemplateModelCode`
37+
generates typed code for it. The keys of `data` are the template's field names. Date fields take `YYYY-MM-DD`.
38+
- Template IDs look like `tpl_...` and submission IDs like `sub_...`. Store the submission ID with your own record.
39+
- Pass `test: true` while you build: test PDFs are free and watermarked. Live PDFs use credits.
40+
- A submission uses the template's latest published version (its draft when nothing has been published yet). Pass
41+
`version` (`draft`, `1.2.0`, or `1` for the latest 1.x.x) to use another one.
42+
- `createSubmission` waits for the PDF, for up to 95 seconds, and returns the submission in
43+
its final state: check its `state` (`processed`, or a failure state with an `error_message`). If the PDF takes longer,
44+
the call fails with a 504 `polling_timeout` error that has the submission's ID. The submission exists and is still
45+
being made, so don't send the request again (that makes a second one): get it with
46+
`getSubmission` until its state isn't `pending`. For slow templates or many PDFs, set
47+
`wait` to false and use webhooks (https://docspring.com/docs/api-guide/synchronous-requests/).
48+
`createSubmissionBatch` sends up to 50 submissions in one request.
49+
- `files.pdf.download_url` is a temporary link. Keep the submission ID (or `files.pdf.permanent_url`, which needs your
50+
API token) and get a fresh link when someone downloads the PDF.
51+
- Submission data is often personal data: don't log request or response bodies. `expires_in` deletes a submission's PDF
52+
and data that many seconds after it's created, and `expireSubmission` deletes them now.
53+
54+
## Errors
55+
56+
- Methods throw `com.docspring.ApiException` for an error response, with the HTTP status in `getCode()` and the body in `getResponseBody()`.
57+
- Every error response has one body: `{"error": {"code", "message", "details", "request_id"}}`. Branch on `code`, not
58+
on the message. Each detail has a `pointer` to the request body value it's about, or the query `parameter`.
59+
- 422 `invalid_data`: the data doesn't match the template. The submission is saved anyway, as `invalid_data`, and the
60+
error has its `submission_id`.
61+
- 402 `insufficient_credits`: the submission is saved and is made automatically once the account has credits. Don't
62+
send it again (https://docspring.com/docs/api-guide/credits-and-rate-limits/).
63+
- 429 `rate_limited`: wait for the seconds in the `Retry-After` header, then retry.
64+
- Requests are checked against the API's request schemas before they're sent. A request the API would reject throws a `com.docspring.ValidationException` (an `IllegalArgumentException`), whose `getDetails()` are `ErrorDetail`s with a code, a message and a pointer into the body (or a parameter). Turn the check off with `apiClient.setValidateRequests(false)`.
65+
66+
## Webhooks
67+
68+
- Webhooks tell your server when a submission is processed or fails, instead of polling
69+
(https://docspring.com/docs/webhooks/overview/). A webhook created with API v2 sends events in API v2's format
70+
(version 4).
71+
- Verify each request's `X-DocSpring-Signature` header before acting on it: an HMAC-SHA256 of `{t}.{raw body}` with the
72+
webhook's signing secret, computed over the raw body exactly as received
73+
(https://docspring.com/docs/webhooks/verifying-signatures/).
74+
- No webhook is sent when a submission starts waiting for credits.
75+
76+
## Signature requests
77+
78+
- To have people fill in fields and sign before the PDF is made, create the submission with `signature_requests`. Each
79+
one has the `fields` its signer fills in (a field belongs to one signature request), and their `name` and `email`.
80+
The PDF is made when every signer has finished
81+
(https://docspring.com/docs/api-guide/create-signature-requests/).
82+
- Send a signer to the `signature_request_url` of a token from
83+
`createSignatureRequestToken`. An `api` token's link opens the form for 24 hours and an
84+
`email` token's for 7 days (`expires_at`), so create a new token when a signer comes back later.
85+
- To show the signing form on your own site, use Signature Requests JS, and add the site's domain to the template's
86+
Embed Domains (https://docspring.com/docs/guides/embedded-forms/embedded-signature-requests/).
87+
88+
## Responses
89+
90+
- List methods return `data` and `next_cursor`: pass `next_cursor` as `cursor` to get the next page.
91+
- Responses can be newer than this SDK, because DocSpring adds fields and enum values to API v2 without a new
92+
version. The model keeps a response field added to the API after this release in its additional properties (`getAdditionalProperties()`). The objects defined inside a model, such as a template's `document`, leave it out. Enum values in responses are strings, so a
93+
value added after this release comes back as it is: handle values you don't recognize.

0 commit comments

Comments
 (0)