Skip to main content
POST
Drafts a new DOCX or PDF file. What it does depends on what you send: A blueprint is a document with placeholders, such as your standard NDA. Find one with List blueprints and read its placeholders with Get blueprint. The blueprint must be published. Give context in any mix of four forms:
  • instructions: what to draft, or how to fill the blueprint.
  • context: free text, such as a deal summary or an email from the business.
  • file_ids: source documents, such as a term sheet or the heads of terms.
  • session_id: a past Wordsmith conversation about the deal.
Each draft runs in a new Wordsmith conversation, so you can open it in the app and keep working on it. Drafting can take a minute or more, so the call returns an operation. Its resource is that conversation, { "type": "session" }. Its id is null until the draft has started. A draft cancelled before it starts opens no conversation. A blueprint filled from your own values usually comes back succeeded within a wait of a few seconds. See Long-running operations for how to wait for the rest. On success, result holds:
  • file_id: the new document, in your own files. Read it with Get file download.
  • values: for a blueprint, every placeholder value used, keyed by placeholder key. A value nothing was found for is null and left blank. To correct one, send the edited values back with the same blueprint_id and no context; no AI runs the second time. null for a draft without a blueprint.
  • url: opens the conversation in Wordsmith, where the user can keep working on the draft.
  • incomplete: true when drafting was cut off part-way, so the file holds only the text drafted until then. Tell the user before relying on it, or ask Wordsmith to finish it in the conversation at url. Always false for a blueprint.
The operation fails with error.code:
  • missing_values: a required placeholder still has no value. The message names it; send it in values.
  • no_document: the agent answered without drafting a document. Try clearer instructions.
  • blueprint_unreadable: Wordsmith could not read the blueprint’s text, so AI could not draft its values from your context. Retrying will not help. Send every value in values with no context, or contact Wordsmith support.
  • draft_failed: anything else went wrong, or the draft stopped without finishing. Retrying is safe.
  • An API error code, such as resource_not_found: the blueprint, a file or the session became unreadable while the draft ran. The message says what; retrying the same request will not help.

Authentication

Requires an API key, or an OAuth token with files:write and files:read: you need files:read to poll the operation and download the draft. Add blueprints:read to pass blueprint_id and sessions:read to pass session_id.

Headers

string
A unique key for this request. A retry with the same key and body within 30 days returns the same operation instead of drafting twice. See Retrying safely.

Body parameters

string
What to draft, up to 10,000 characters. For example: “A two-page side letter extending the exclusivity period to 31 March.” Required without blueprint_id. With a blueprint, it steers how AI drafts the empty placeholders.
string
The blueprint to draft from.
object
Blueprint placeholder values you already know, keyed by placeholder key. AI never overrides them. Each value must fit its placeholder’s type: a string (or number) for text, one of the options for choice, a list of options for multi_choice, true or false for boolean, and rows of strings for table. Only with blueprint_id.
string
Free-text context, up to 20,000 characters.
string[]
Up to 10 source documents, as file_ids from the files API. A file_id comes from Complete upload or Import file, not from Upload URL, which returns a job_id.
string
A past conversation to use as context, from List sessions.
string
default:"docx"
docx or pdf.
string
The name of the new file, without an extension, up to 255 characters. Defaults to the blueprint’s or the draft’s name, plus the date.
integer
default:"0"
Seconds to wait for the operation to finish before responding, from 0 to 20.
string
An HTTPS URL that receives a signed POST with the operation when it finishes. An API key signs it with its webhook secret. For an OAuth app, the response carries the callback_secret that signs it. See Callbacks for OAuth apps.

Query parameters

boolean
default:"false"
true answers an operation that is still queued or running with 202 Accepted, a Location header and a Retry-After header in seconds. Location is the operation’s Get operation URL, with respond_async=true. Poll it until the response is not 202; that response is the finished operation. A succeeded operation is a 200. A failed or cancelled one is a 422 with the operation as its body, so an automation’s step fails instead of passing on a result that is not there. Power Automate and Logic Apps follow this pattern by themselves. Pass true to turn it on. A value that is not a boolean is a 400, and a call that starts work then starts nothing.

Response

Returns 202 with the operation, of type draft. A repeat with the same Idempotency-Key returns 200 with the same operation. With respond_async=true, the status code follows the operation’s status instead, as the respond_async query parameter above describes.

Errors