---
title: "Create a contract"
method: POST
path: "/contract/create"
tags: ["Contracts"]
---

# Create a contract

`POST /contract/create`

## Request

- Base URL: `https://apisign.io/api`
- URL: `https://apisign.io/api/contract/create`
- Auth: API key in header `x-api-key`

Create a draft contract from a template (`template_id` + `variables`) or from your own markdown (`content` + `fields`). Nothing is emailed or charged until `/contract/send`. The content must contain at least one signer-completed signature field; with more than one signer, every signer needs `signerFields` that include a signature field of their own.

## Request body

- CreateContractRequest
  - `name` string, required
  - `template_id` string: Active template ID (cuid). Omit for a blank contract.
  - `content` string: Markdown. Required for blank contracts; rejected with template_id.
  - `variables` object: Values substituted into the template. Required for every creator-completed template field. Rejected for blank contracts.
  - `fields` FieldDefinition[]: Required for blank contracts; rejected with template_id.
    - `name` string, required: Variable name without braces
    - `type` string, required: signature, initials, signer_name, timestamp, text, email, phone or date
    - `completedBy` 'signer' | 'creator', required
    - `label` string: Prompt shown for a text field
  - `signers` CreateSignerInput[], required
    - `email` string, email, required
    - `name` string, required
    - `signing_order` integer, required: Unique per contract. Display order only; does not enforce a signing sequence.
    - `company` string
    - `mobile` string: Stored only; nothing is sent to it
    - `signerFields` string[]: Variable names this signer fills in. Required on every signer when there is more than one signer; each needs a signature field no other signer has.
  - `expires_in_days` integer
  - `test_mode` boolean: Fixed at creation
  - `metadata` object

## Response `200`

Draft contract created

- object
  - `success` boolean
  - `contract` Contract
    - `id` string
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `status` 'draft' | 'queued' | 'sent' | 'signed' | 'cancelled' | 'expired': `queued` is not set by any endpoint. `expired` is not currently set automatically: a contract past `expires_at` stays `sent`.
    - `org_id` string
    - `sent_at` string, date-time, nullable
    - `expires_at` string, date-time, nullable: Creation time plus expires_in_days. Signing links stop working after this.
    - `cancelled_at` string, date-time, nullable
    - `name` string
    - `content` object
      - `markdown` string
    - `fields` StoredFields, nullable: Field data as stored on a contract or template
      - `fields` FieldDefinition[]
        - `name` string, required: Variable name without braces
        - `type` string, required: signature, initials, signer_name, timestamp, text, email, phone or date
        - `completedBy` 'signer' | 'creator', required
        - `label` string: Prompt shown for a text field
      - `signers` object[]: Per-signer field assignments, matched to signers by signing_order
        - `signing_order` integer
        - `signerFields` string[]
    - `template_id` string, nullable
    - `final_pdf` string: URL of the signed PDF; empty string until every signer has signed
    - `metadata` object
    - `test_mode` boolean
    - `seal_document_hash` string, nullable
    - `seal_created_at` string, date-time, nullable
    - `seal_certificate_serial` string, nullable
  - `signers` Signer[]
    - `id` string
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `org_id` string
    - `contract_id` string
    - `email` string, email
    - `name` string
    - `mobile` string, nullable
    - `company` string
    - `signing_order` integer: Display order. Unique per contract. Does not enforce a signing sequence: all signers are emailed at once and may sign in any order.
    - `status` 'pending' | 'signed' | 'declined'
    - `test_mode` boolean
    - `signature_data` string, nullable: Base64 signature image
    - `signed_at` string, date-time, nullable
    - `field_values` object, nullable: Values this signer submitted

## Other responses

- `400`: Invalid request, or the action is not allowed in the resource's current state
- `401`: Missing, invalid, expired or deleted API key. Body: `{ "error": "Unauthorized" }`
- `404`: Resource not found in this organization
- `500`: Internal server error (also returned for a request body that is not valid JSON)

---

[API](https://skmtc.dev/apisign/apis/api-sign-api.md) · [All operations](https://skmtc.dev/apisign/apis/api-sign-api/llms.txt) · [OpenAPI document](https://skmtc.dev/apisign/apis/api-sign-api/revisions/fa21d8adbc69?raw)
