Docspring.Api.Client (docspring v4.0.0)

API calls for all endpoints tagged Client.

Summary

Functions

Copy a template Copies a template (its draft, or a published version) into a new template.

Combine PDFs Merges PDFs into one: submissions, other combined PDFs, templates, custom files (POST /custom_files) and PDFs from URLs, in the order of source_pdfs. The PDF is generated in the background: on sync.api hosts the request waits for it (unless you pass wait=false), otherwise poll GET /combined_pdfs/{combined_pdf_id} until state isn't pending. A template source merges the template's processed PDF by default: the PDF submissions are filled in on, decrypted and with its form fields removed. Pass processed: false to merge the PDF as it was uploaded.

Create a custom file from an upload Creates a custom file from a PDF you uploaded, so you can merge it with other PDFs. Upload the file with the presigned upload (GET /uploads/presign) first, then pass its fields.key as cache_id.

Create a folder Creates a folder for organizing templates. Pass parent_folder_id to create it inside another folder. Folder names are unique within their parent folder.

Record a signature request event Records something that happened outside DocSpring in the signature request's audit trail: you sent the request to the person (send_request). The audit trail shows it as reported by your account.

Create a signature request token Creates a token that opens the signature request without signing in, in a form embedded in your app or from a link you send. The response is the only time the token's secret is returned. The link works for 24 hours, or 7 days for an email token, and a signing page that opened in time keeps working for 7 more days. A test API token can't create a token for a live signature request.

Generate a PDF Creates a submission: fills in a template with your data and generates a PDF. The PDF is generated in the background: on sync.api hosts the request waits for it (unless you pass wait=false), otherwise poll GET /submissions/{submission_id} until state isn't pending. Data that doesn't match the template's fields returns a 422 with an invalid_data error. The submission is still saved, with its errors, so you can find it in DocSpring: the error's submission_id is its ID.

Generate PDFs in a batch Creates up to 50 submissions in one request, from one template or several. The PDFs are only generated when every submission is valid. On sync.api hosts the request waits until every PDF has been generated (unless you pass wait=false), otherwise poll GET /submissions/batches/{submission_batch_id} until processed_at is set. When any submission is invalid, nothing is generated and the request returns a 422. Submissions whose data doesn't match their template's fields are still saved with their errors (an invalid_data error, with each one's submission_id in its details), so you can find them in DocSpring. The other submissions aren't saved.

Create a template Creates an HTML template, or a PDF template from a PDF you uploaded with the presigned upload (GET /uploads/presign): pass its fields.key as cache_id. To send the PDF with the request instead, use POST /templates/upload. A PDF template is ready to generate PDFs once DocSpring has processed its PDF (ready is true). On sync.api hosts the request waits for that unless you pass wait=false.

Create a webhook Creates a webhook that sends a POST request to your endpoint whenever a subscribed event happens. Scope it to API tokens, templates or folders to receive only their events.

Delete a custom file Deletes a custom file and returns it. Use a live API token: test tokens can't delete custom files.

Delete a folder Deletes an empty folder and returns it. A folder that still has templates or folders in it can't be deleted.

Delete a template Deletes a template's draft and all of its published versions, or one published version (version). Returns the template as it was before it was deleted.

Delete a webhook Deletes a webhook so it stops receiving events, and returns it.

Expire a combined PDF Deletes a combined PDF's PDF and returns the expired combined PDF.

Expire a submission Deletes a submission's data and PDF now, and returns the expired submission.

Generate a preview PDF Generates a preview of a submission's PDF in the background, such as for a submission still waiting for its signature requests. It's in files.preview once preview_generated_at changes.

Get a combined PDF Returns a combined PDF, with a temporary link to download it once it has been generated.

Get a custom file Returns a custom file, with a temporary URL to download it.

Get a folder Returns a folder.

Get a presigned URL to upload a file Returns a presigned S3 form for uploading a file directly to DocSpring, for files too large to send in a request body. POST the fields and the file (as file) to url as multipart/form-data, then pass fields.key as the cache_id when you create a custom file.

Get a signature request Returns a signature request, with the values the person has entered so far.

Get a submission Returns a submission, with its data and links to download its PDF.

Get a batch Returns a batch with its submissions. The batch has finished once processed_at is set: its state is processed when every PDF was generated, or error when any submission failed.

Get a template Returns a template: its draft, or one of its published versions.

Generate typed code for a template's submission data Generates types for a template's submission data in TypeScript, JavaScript, Ruby, Python, PHP, Java, C#, Elixir or Go, so your app catches mistakes before it calls the API. root_type_name is the type of the whole data object. Java returns every class in code, each under a // ClassName.java comment. A template with no named fields returns 422.

Get the JSON Schema of a template's submission data Returns the JSON Schema that a submission's data must match. Use it to check data before you create submissions, or to build a form for the template's fields.

Get a webhook Returns a webhook.

List combined PDFs Returns the combined PDFs in your account, newest first, one page at a time.

List custom files Returns the custom files in your account, newest first, one page at a time.

List folders Returns the folders in your account, newest first, one page at a time. Pass parent_folder_id to list the folders in one folder.

List submissions Returns the submissions in your account, newest first, one page at a time. Lists leave out each submission's data unless you pass include_data=true.

List a template's submissions Returns a template's submissions (from every version of the template), newest first.

List templates Returns the templates in your account (their drafts), newest first, one page at a time. Get a template by its ID for its HTML, defaults and published versions.

List webhooks Returns the webhooks in your account, newest first, one page at a time. Filter them by event type, mode, or the API token, template or folder they're scoped to.

Move a folder Moves a folder into another folder, or to the root with parent_folder_id: null. Its templates and folders move with it. A folder can't move into itself or one of its own folders.

Move a template to a folder Moves a template and all of its published versions to a folder, or to the root (null).

Publish a template version Publishes the template's draft as a new version that doesn't change. version_type says which part of the latest version number goes up.

Rename a folder Renames a folder. The name must be unique within its parent folder.

Restore a template version Replaces the template's draft with a copy of one of its published versions.

Test authentication Checks whether your API token is valid by making an authenticated request. This endpoint is useful for verifying credentials during setup or troubleshooting issues.

Update a signature request Changes a pending signature request's metadata, or how your app authenticated the person (for the audit trail). Once the person has opened it, only its metadata can be changed, and a completed or declined signature request can't be changed.

Update a template Changes a template's draft. Properties left out keep their values. defaults and html_engine_options replace the whole object. Setting parent_folder_id moves the template and all of its published versions.

Replace a template's PDF Replaces a PDF template's PDF with one you uploaded with the presigned upload (GET /uploads/presign). The fields stay where they are, unless reimport_fields replaces them with the new PDF's fillable fields. To send the PDF with the request instead, use PUT /templates/{template_id}/document/upload.

Update a webhook Updates a webhook. Only the properties you send change.

Create a PDF template from an uploaded PDF Creates a PDF template from a PDF sent with the request (multipart/form-data). For large files, upload the PDF with the presigned upload (GET /uploads/presign) and create the template with POST /templates.

Replace a template's PDF with an uploaded PDF Replaces a PDF template's PDF with one sent with the request (multipart/form-data). The fields stay where they are, unless reimport_fields replaces them with the new PDF's fillable fields.

Functions

copy_template(connection, template_id, opts \\ [])

@spec copy_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Template.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Copy a template Copies a template (its draft, or a published version) into a new template.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • opts (keyword): Optional parameters
    • :body (CopyTemplateRequest): Settings for the copy.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_combined_pdf(connection, body, opts \\ [])

Combine PDFs Merges PDFs into one: submissions, other combined PDFs, templates, custom files (POST /custom_files) and PDFs from URLs, in the order of source_pdfs. The PDF is generated in the background: on sync.api hosts the request waits for it (unless you pass wait=false), otherwise poll GET /combined_pdfs/{combined_pdf_id} until state isn't pending. A template source merges the template's processed PDF by default: the PDF submissions are filled in on, decrypted and with its form fields removed. Pass processed: false to merge the PDF as it was uploaded.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateCombinedPdfRequest): The PDFs to merge, and the combined PDF's settings.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until the PDF has been generated before responding. Default true on sync.api hosts.

Returns

  • {:ok, Docspring.Model.CombinedPdf.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_custom_file_from_upload(connection, body, opts \\ [])

Create a custom file from an upload Creates a custom file from a PDF you uploaded, so you can merge it with other PDFs. Upload the file with the presigned upload (GET /uploads/presign) first, then pass its fields.key as cache_id.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateCustomFileFromUploadRequest): The uploaded file to create the custom file from.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.CustomFile.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_folder(connection, body, opts \\ [])

Create a folder Creates a folder for organizing templates. Pass parent_folder_id to create it inside another folder. Folder names are unique within their parent folder.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateFolderRequest): The folder to create.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Folder.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_signature_request_event(connection, signature_request_id, body, opts \\ [])

Record a signature request event Records something that happened outside DocSpring in the signature request's audit trail: you sent the request to the person (send_request). The audit trail shows it as reported by your account.

Parameters

  • connection (Docspring.Connection): Connection to server
  • signature_request_id (String.t): The signature request's ID.
  • body (CreateSignatureRequestEventRequest): The event to record.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.SignatureRequestEvent.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_signature_request_token(connection, signature_request_id, opts \\ [])

@spec create_signature_request_token(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.SignatureRequestToken.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Create a signature request token Creates a token that opens the signature request without signing in, in a form embedded in your app or from a link you send. The response is the only time the token's secret is returned. The link works for 24 hours, or 7 days for an email token, and a signing page that opened in time keeps working for 7 more days. A test API token can't create a token for a live signature request.

Parameters

  • connection (Docspring.Connection): Connection to server
  • signature_request_id (String.t): The signature request's ID.
  • opts (keyword): Optional parameters
    • :body (CreateSignatureRequestTokenRequest): The kind of link to make. Send no body for an api token.

Returns

  • {:ok, Docspring.Model.SignatureRequestToken.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_submission(connection, template_id, body, opts \\ [])

Generate a PDF Creates a submission: fills in a template with your data and generates a PDF. The PDF is generated in the background: on sync.api hosts the request waits for it (unless you pass wait=false), otherwise poll GET /submissions/{submission_id} until state isn't pending. Data that doesn't match the template's fields returns a 422 with an invalid_data error. The submission is still saved, with its errors, so you can find it in DocSpring: the error's submission_id is its ID.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (CreateSubmissionRequest): The submission's data and settings.
  • opts (keyword): Optional parameters
    • :version (String.t): The template version to use: a published version (1.2.0, or 1 for the latest 1.x.x), latest or draft. Default latest (the draft when no version has been published).
    • :wait (boolean()): Wait until the PDF has been generated before responding. Default true on sync.api hosts.

Returns

  • {:ok, Docspring.Model.Submission.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_submission_batch(connection, body, opts \\ [])

Generate PDFs in a batch Creates up to 50 submissions in one request, from one template or several. The PDFs are only generated when every submission is valid. On sync.api hosts the request waits until every PDF has been generated (unless you pass wait=false), otherwise poll GET /submissions/batches/{submission_batch_id} until processed_at is set. When any submission is invalid, nothing is generated and the request returns a 422. Submissions whose data doesn't match their template's fields are still saved with their errors (an invalid_data error, with each one's submission_id in its details), so you can find them in DocSpring. The other submissions aren't saved.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateSubmissionBatchRequest): The submissions to create, and the settings they share.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until every PDF in the batch has been generated before responding. Default true on sync.api hosts.

Returns

  • {:ok, Docspring.Model.SubmissionBatch.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_template(connection, body, opts \\ [])

Create a template Creates an HTML template, or a PDF template from a PDF you uploaded with the presigned upload (GET /uploads/presign): pass its fields.key as cache_id. To send the PDF with the request instead, use POST /templates/upload. A PDF template is ready to generate PDFs once DocSpring has processed its PDF (ready is true). On sync.api hosts the request waits for that unless you pass wait=false.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateTemplateRequest): The template to create.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until the PDF has been processed before responding. Default true on sync.api hosts.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

create_webhook(connection, body, opts \\ [])

Create a webhook Creates a webhook that sends a POST request to your endpoint whenever a subscribed event happens. Scope it to API tokens, templates or folders to receive only their events.

Parameters

  • connection (Docspring.Connection): Connection to server
  • body (CreateWebhookRequest): The webhook to create.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Webhook.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

delete_custom_file(connection, custom_file_id, opts \\ [])

@spec delete_custom_file(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.CustomFile.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a custom file Deletes a custom file and returns it. Use a live API token: test tokens can't delete custom files.

Parameters

  • connection (Docspring.Connection): Connection to server
  • custom_file_id (String.t): The custom file's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.CustomFile.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

delete_folder(connection, folder_id, opts \\ [])

@spec delete_folder(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Folder.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a folder Deletes an empty folder and returns it. A folder that still has templates or folders in it can't be deleted.

Parameters

  • connection (Docspring.Connection): Connection to server
  • folder_id (String.t): The folder's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Folder.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

delete_template(connection, template_id, opts \\ [])

@spec delete_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Template.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a template Deletes a template's draft and all of its published versions, or one published version (version). Returns the template as it was before it was deleted.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • opts (keyword): Optional parameters
    • :version (String.t): Delete only this published version (1.2.0) or the draft (draft, when no version has been published). Without it, the draft and every published version are deleted.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

delete_webhook(connection, webhook_id, opts \\ [])

@spec delete_webhook(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Webhook.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Delete a webhook Deletes a webhook so it stops receiving events, and returns it.

Parameters

  • connection (Docspring.Connection): Connection to server
  • webhook_id (String.t): The webhook's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Webhook.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

expire_combined_pdf(connection, combined_pdf_id, opts \\ [])

@spec expire_combined_pdf(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.CombinedPdf.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Expire a combined PDF Deletes a combined PDF's PDF and returns the expired combined PDF.

Parameters

  • connection (Docspring.Connection): Connection to server
  • combined_pdf_id (String.t): The combined PDF's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.CombinedPdf.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

expire_submission(connection, submission_id, opts \\ [])

@spec expire_submission(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Submission.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Expire a submission Deletes a submission's data and PDF now, and returns the expired submission.

Parameters

  • connection (Docspring.Connection): Connection to server
  • submission_id (String.t): The submission's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Submission.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

generate_submission_preview(connection, submission_id, opts \\ [])

@spec generate_submission_preview(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Submission.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Generate a preview PDF Generates a preview of a submission's PDF in the background, such as for a submission still waiting for its signature requests. It's in files.preview once preview_generated_at changes.

Parameters

  • connection (Docspring.Connection): Connection to server
  • submission_id (String.t): The submission's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Submission.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_combined_pdf(connection, combined_pdf_id, opts \\ [])

@spec get_combined_pdf(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.CombinedPdf.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a combined PDF Returns a combined PDF, with a temporary link to download it once it has been generated.

Parameters

  • connection (Docspring.Connection): Connection to server
  • combined_pdf_id (String.t): The combined PDF's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.CombinedPdf.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_custom_file(connection, custom_file_id, opts \\ [])

@spec get_custom_file(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.CustomFile.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a custom file Returns a custom file, with a temporary URL to download it.

Parameters

  • connection (Docspring.Connection): Connection to server
  • custom_file_id (String.t): The custom file's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.CustomFile.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_folder(connection, folder_id, opts \\ [])

@spec get_folder(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Folder.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a folder Returns a folder.

Parameters

  • connection (Docspring.Connection): Connection to server
  • folder_id (String.t): The folder's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Folder.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_presign_url(connection, opts \\ [])

@spec get_presign_url(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.UploadPresign.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a presigned URL to upload a file Returns a presigned S3 form for uploading a file directly to DocSpring, for files too large to send in a request body. POST the fields and the file (as file) to url as multipart/form-data, then pass fields.key as the cache_id when you create a custom file.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.UploadPresign.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_signature_request(connection, signature_request_id, opts \\ [])

@spec get_signature_request(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.SignatureRequest.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a signature request Returns a signature request, with the values the person has entered so far.

Parameters

  • connection (Docspring.Connection): Connection to server
  • signature_request_id (String.t): The signature request's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.SignatureRequest.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_submission(connection, submission_id, opts \\ [])

@spec get_submission(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Submission.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a submission Returns a submission, with its data and links to download its PDF.

Parameters

  • connection (Docspring.Connection): Connection to server
  • submission_id (String.t): The submission's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Submission.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_submission_batch(connection, submission_batch_id, opts \\ [])

@spec get_submission_batch(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.SubmissionBatch.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a batch Returns a batch with its submissions. The batch has finished once processed_at is set: its state is processed when every PDF was generated, or error when any submission failed.

Parameters

  • connection (Docspring.Connection): Connection to server
  • submission_batch_id (String.t): The batch's ID.
  • opts (keyword): Optional parameters
    • :include_data (boolean()): Include each submission's data (null without it).

Returns

  • {:ok, Docspring.Model.SubmissionBatch.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_template(connection, template_id, opts \\ [])

@spec get_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Template.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a template Returns a template: its draft, or one of its published versions.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • opts (keyword): Optional parameters
    • :version (String.t): A published version (1.2.0, or 1 for the latest 1.x.x), latest or draft. Default draft.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_template_model_code(connection, template_id, lang, opts \\ [])

Generate typed code for a template's submission data Generates types for a template's submission data in TypeScript, JavaScript, Ruby, Python, PHP, Java, C#, Elixir or Go, so your app catches mistakes before it calls the API. root_type_name is the type of the whole data object. Java returns every class in code, each under a // ClassName.java comment. A template with no named fields returns 422.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • lang (ModelCodeLanguage): The language to generate the code in.
  • opts (keyword): Optional parameters
    • :version (String.t): The template version: a published version (1.2.0, or 1 for the latest 1.x.x), latest or draft. Default latest (the draft when no version has been published), the version a submission uses by default.

Returns

  • {:ok, Docspring.Model.TemplateModelCode.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_template_schema(connection, template_id, opts \\ [])

@spec get_template_schema(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get the JSON Schema of a template's submission data Returns the JSON Schema that a submission's data must match. Use it to check data before you create submissions, or to build a form for the template's fields.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • opts (keyword): Optional parameters
    • :version (String.t): The template version: a published version (1.2.0, or 1 for the latest 1.x.x), latest or draft. Default latest (the draft when no version has been published), the version a submission uses by default.

Returns

  • {:ok, %{optional(String.t) => any()}} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

get_webhook(connection, webhook_id, opts \\ [])

@spec get_webhook(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Webhook.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Get a webhook Returns a webhook.

Parameters

  • connection (Docspring.Connection): Connection to server
  • webhook_id (String.t): The webhook's ID.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Webhook.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_combined_pdfs(connection, opts \\ [])

@spec list_combined_pdfs(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.CombinedPdfList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List combined PDFs Returns the combined PDFs in your account, newest first, one page at a time.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.CombinedPdfList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_custom_files(connection, opts \\ [])

@spec list_custom_files(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.CustomFileList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List custom files Returns the custom files in your account, newest first, one page at a time.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.CustomFileList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_folders(connection, opts \\ [])

@spec list_folders(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.FolderList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List folders Returns the folders in your account, newest first, one page at a time. Pass parent_folder_id to list the folders in one folder.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :parent_folder_id (String.t): Only list the folders in this folder. Without it, the list has every folder, at any depth.
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.FolderList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_submissions(connection, opts \\ [])

@spec list_submissions(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.SubmissionList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List submissions Returns the submissions in your account, newest first, one page at a time. Lists leave out each submission's data unless you pass include_data=true.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :template_id (String.t): Only list this template's submissions.
    • :test (boolean()): Only list test submissions (true) or live submissions (false).
    • :created_after (DateTime.t): Only list submissions created after this time (RFC 3339, such as 2025-01-31T09:00:00Z).
    • :created_before (DateTime.t): Only list submissions created before this time.
    • :include_data (boolean()): Include each submission's data (null without it).
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.SubmissionList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_template_submissions(connection, template_id, opts \\ [])

@spec list_template_submissions(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.SubmissionList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List a template's submissions Returns a template's submissions (from every version of the template), newest first.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • opts (keyword): Optional parameters
    • :test (boolean()): Only list test submissions (true) or live submissions (false).
    • :created_after (DateTime.t): Only list submissions created after this time (RFC 3339, such as 2025-01-31T09:00:00Z).
    • :created_before (DateTime.t): Only list submissions created before this time.
    • :include_data (boolean()): Include each submission's data (null without it).
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.SubmissionList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_templates(connection, opts \\ [])

@spec list_templates(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.TemplateSummaryList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List templates Returns the templates in your account (their drafts), newest first, one page at a time. Get a template by its ID for its HTML, defaults and published versions.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :query (String.t): Only list templates whose name contains this text (ignoring case).
    • :parent_folder_id (String.t): Only list the templates in this folder (not in its subfolders).
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.TemplateSummaryList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

list_webhooks(connection, opts \\ [])

@spec list_webhooks(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.WebhookList.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

List webhooks Returns the webhooks in your account, newest first, one page at a time. Filter them by event type, mode, or the API token, template or folder they're scoped to.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :event_type (WebhookEventType): Only list webhooks that subscribe to this event.
    • :mode (WebhookMode): Only list webhooks set to this mode.
    • :template_id (String.t): Only list webhooks scoped to this template.
    • :folder_id (String.t): Only list webhooks scoped to this folder.
    • :api_token_id (String.t): Only list webhooks scoped to this API token.
    • :limit (integer()): How many items to return (1-100, default 50).
    • :cursor (String.t): The previous page's next_cursor, to get the next page. It's the ID of that page's last item, so get the next page before you delete or change the items on this one.

Returns

  • {:ok, Docspring.Model.WebhookList.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

move_folder(connection, folder_id, body, opts \\ [])

Move a folder Moves a folder into another folder, or to the root with parent_folder_id: null. Its templates and folders move with it. A folder can't move into itself or one of its own folders.

Parameters

  • connection (Docspring.Connection): Connection to server
  • folder_id (String.t): The folder's ID.
  • body (MoveFolderRequest): Where to move the folder.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Folder.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

move_template(connection, template_id, body, opts \\ [])

Move a template to a folder Moves a template and all of its published versions to a folder, or to the root (null).

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (MoveTemplateRequest): Where to move the template.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

publish_template_version(connection, template_id, body, opts \\ [])

Publish a template version Publishes the template's draft as a new version that doesn't change. version_type says which part of the latest version number goes up.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (PublishTemplateVersionRequest): The version to publish.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.TemplateVersion.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

rename_folder(connection, folder_id, body, opts \\ [])

Rename a folder Renames a folder. The name must be unique within its parent folder.

Parameters

  • connection (Docspring.Connection): Connection to server
  • folder_id (String.t): The folder's ID.
  • body (RenameFolderRequest): The folder's new name.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Folder.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

restore_template_version(connection, template_id, body, opts \\ [])

Restore a template version Replaces the template's draft with a copy of one of its published versions.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (RestoreTemplateVersionRequest): The version to restore.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

test_authentication(connection, opts \\ [])

@spec test_authentication(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Docspring.Model.AuthenticationCheck.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Test authentication Checks whether your API token is valid by making an authenticated request. This endpoint is useful for verifying credentials during setup or troubleshooting issues.

Parameters

  • connection (Docspring.Connection): Connection to server
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.AuthenticationCheck.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

update_signature_request(connection, signature_request_id, body, opts \\ [])

Update a signature request Changes a pending signature request's metadata, or how your app authenticated the person (for the audit trail). Once the person has opened it, only its metadata can be changed, and a completed or declined signature request can't be changed.

Parameters

  • connection (Docspring.Connection): Connection to server
  • signature_request_id (String.t): The signature request's ID.
  • body (UpdateSignatureRequestRequest): The settings to change. Properties left out keep their values.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.SignatureRequest.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

update_template(connection, template_id, body, opts \\ [])

Update a template Changes a template's draft. Properties left out keep their values. defaults and html_engine_options replace the whole object. Setting parent_folder_id moves the template and all of its published versions.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (UpdateTemplateRequest): The settings to change. Properties left out keep their values.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

update_template_document(connection, template_id, body, opts \\ [])

Replace a template's PDF Replaces a PDF template's PDF with one you uploaded with the presigned upload (GET /uploads/presign). The fields stay where they are, unless reimport_fields replaces them with the new PDF's fillable fields. To send the PDF with the request instead, use PUT /templates/{template_id}/document/upload.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • body (UpdateTemplateDocumentRequest): The new PDF.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until the PDF has been processed before responding. Default true on sync.api hosts.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

update_webhook(connection, webhook_id, body, opts \\ [])

Update a webhook Updates a webhook. Only the properties you send change.

Parameters

  • connection (Docspring.Connection): Connection to server
  • webhook_id (String.t): The webhook's ID.
  • body (UpdateWebhookRequest): The settings to change. Properties left out keep their values.
  • opts (keyword): Optional parameters

Returns

  • {:ok, Docspring.Model.Webhook.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

upload_template(connection, document, opts \\ [])

@spec upload_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Template.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Create a PDF template from an uploaded PDF Creates a PDF template from a PDF sent with the request (multipart/form-data). For large files, upload the PDF with the presigned upload (GET /uploads/presign) and create the template with POST /templates.

Parameters

  • connection (Docspring.Connection): Connection to server
  • document (String.t): The PDF.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until the PDF has been processed before responding. Default true on sync.api hosts.
    • :name (String.t): The template's name.
    • :description (String.t): The template's description.
    • :parent_folder_id (String.t): The folder to put the template in. Left out, it's created at the root.
    • :ai_field_naming_language (Docspring.Model.AiFieldNamingLanguage.t): The language AI field setup names fields in: auto uses the form's language when it's written in the Latin alphabet without accents, and English otherwise; english always uses English; form_language uses the form's language and script. Default: your account's template settings.
    • :detect_fields (boolean()): Set up the PDF's fields as DocSpring's \"Automatically detect fields\" upload option does: import or detect the fields, name them with AI, and set up conditional logic. field_source, field_naming and field_logic choose how. Default false. document.page_processing_statuses and document.field_logic_status show how it's going, and document.state becomes processed once every page's fields are set up.
    • :field_source (Docspring.Model.FieldSetupSource.t): With detect_fields, where the fields come from. auto (the default) imports the form fields of a fillable PDF and detects the fields of a PDF without them; pdf_detection detects the fields from the page layout, even on a fillable PDF; pdf_form_fields only imports the PDF's form fields.
    • :field_naming (Docspring.Model.FieldSetupNaming.t): With detect_fields, how the fields are named. ai (the default) names them and sets their types and settings with AI; preserve keeps the names of the PDF's form fields, and AI only names the fields it detected. preserve needs field_source auto or pdf_form_fields.
    • :field_logic (Docspring.Model.FieldSetupLogic.t): With detect_fields, whether AI reads the whole form once the fields are named and sets up conditional logic and required fields (ai) or not (none). Default: your account's template settings.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure

upload_template_document(connection, template_id, document, opts \\ [])

@spec upload_template_document(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Docspring.Model.Template.t()}
  | {:ok, Docspring.Model.ErrorResponse.t()}
  | {:error, Tesla.Env.t()}

Replace a template's PDF with an uploaded PDF Replaces a PDF template's PDF with one sent with the request (multipart/form-data). The fields stay where they are, unless reimport_fields replaces them with the new PDF's fillable fields.

Parameters

  • connection (Docspring.Connection): Connection to server
  • template_id (String.t): The template's ID.
  • document (String.t): The new PDF.
  • opts (keyword): Optional parameters
    • :wait (boolean()): Wait until the PDF has been processed before responding. Default true on sync.api hosts.
    • :reimport_fields (boolean()): Replace all of the template's fields with the fillable fields in the new PDF, once DocSpring has processed it (document.field_reimport_state). As on a first upload, the default typeface, font size, bold and color are taken from the PDF's fields; the template's other settings are kept. If the PDF has no fillable fields, the template keeps its fields. A locked template can't re-import its fields.

Returns

  • {:ok, Docspring.Model.Template.t} | {:ok, Docspring.Model.ErrorResponse.t} on success

  • {:error, Tesla.Env.t} on failure