Drafts
Create draft
Draft a document from instructions and context, optionally starting from a blueprint.
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.
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 placeholderkey. A value nothing was found for isnulland left blank. To correct one, send the editedvaluesback with the sameblueprint_idand no context; no AI runs the second time.nullfor a draft without a blueprint.url: opens the conversation in Wordsmith, where the user can keep working on the draft.incomplete:truewhen 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 aturl. Alwaysfalsefor a blueprint.
error.code:
missing_values: a required placeholder still has no value. The message names it; send it invalues.no_document: the agent answered without drafting a document. Try clearerinstructions.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 invalueswith 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 withfiles: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
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
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.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.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.A past conversation to use as context, from List sessions.
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.
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
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
Returns202 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.