Skip to content
Internal preview — Billtyme does not issue or send invoices yet.See what's included
Billtyme
Esc
navigateopen⌘Jpreview

Create an invoice

Creates a persisted invoice in draft status, freezes issuer and customer snapshots, and calculates exact line and total amounts. Currency, language, and due date may use company defaults.

POST/v1/companies/{company_id}/invoices
Authorization
AuthorizationBearer token (JWT) · headerrequired
WorkOS AuthKit user, service, or agent access token
Path parameters
company_idstring<uuid>required
Header parameters
idempotency-keystringrequired
min length 8 · max length 255 · matches ^[\u0021-\u007E]+$
Request body
requiredapplication/json
currencystring
matches ^[A-Z]{3}$
customer_idstring<uuid>required
due_datestring<date>
external_referencestring
min length 1 · max length 255
issue_datestring<date>required
languagestring
matches ^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$
linesobject[]required
min items 1 · max items 100
Show properties
Array of object
descriptionstringrequired
min length 1 · max length 500
quantitystringrequired
matches ^(?!0(?:\.0{1,3})?$)(?:0|[1-9]\d{0,8})(?:\.\d{1,3})?$
tax_rate_bpsintegerrequired
min 0 · max 10000
unitstring
min length 1 · max length 32
unit_amount_minorintegerrequired
min 0 · max 9007199254740991
notesstring
max length 5000
purchase_order_referencestring
min length 1 · max length 255
termsstring
max length 5000
Responses
201Draft invoice created or idempotently replayed
company_idstring<uuid>required
created_atstring<date-time>required
currencystringrequired
matches ^[A-Z]{3}$
customerobjectrequired
Show properties
addressobjectrequired
Show properties
citystringrequired
min length 1 · max length 120
country_codestringrequired
matches ^[A-Z]{2}$
line_1stringrequired
min length 1 · max length 200
line_2string
max length 200
postal_codestringrequired
min length 1 · max length 32
regionstring
max length 120
emailstring<email>
idstring<uuid>required
identifiersobject[]
max items 20 · default: []
Show properties
Array of object
country_codestring
matches ^[A-Z]{2}$
schemestringrequired
matches ^[a-z][a-z0-9._-]{0,63}$
valuestringrequired
min length 1 · max length 200
namestringrequired
min length 1 · max length 200
schema_versionintegerrequired
customer_idstring<uuid>required
customer_namestringrequired
min length 1 · max length 200
due_datestring<date> | nullrequired
external_referencestring
min length 1 · max length 255
idstring<uuid>required
issue_datestring<date>required
issued_atstring<date-time> | nullrequired
issuerobjectrequired
Show properties
addressobjectrequired
Show properties
citystringrequired
min length 1 · max length 120
country_codestringrequired
matches ^[A-Z]{2}$
line_1stringrequired
min length 1 · max length 200
line_2string
max length 200
postal_codestringrequired
min length 1 · max length 32
regionstring
max length 120
emailstring<email>
idstring<uuid>required
identifiersobject[]
max items 20 · default: []
Show properties
Array of object
country_codestring
matches ^[A-Z]{2}$
schemestringrequired
matches ^[a-z][a-z0-9._-]{0,63}$
valuestringrequired
min length 1 · max length 200
legal_namestringrequired
min length 1 · max length 200
schema_versionintegerrequired
trading_namestring
min length 1 · max length 200
languagestringrequired
matches ^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$
linesobject[]required
min items 1
Show properties
Array of object
descriptionstringrequired
min length 1 · max length 500
net_amount_minorintegerrequired
min 0 · max 9007199254740991
positionintegerrequired
quantitystringrequired
matches ^(?!0(?:\.0{1,3})?$)(?:0|[1-9]\d{0,8})(?:\.\d{1,3})?$
tax_amount_minorintegerrequired
min 0 · max 9007199254740991
tax_rate_bpsintegerrequired
min 0 · max 10000
total_amount_minorintegerrequired
min 0 · max 9007199254740991
unitstring
min length 1 · max length 32
unit_amount_minorintegerrequired
min 0 · max 9007199254740991
notesstring
max length 5000
numberstring | nullrequired
purchase_order_referencestring
max length 255
statusstringrequired
Allowed:draftissuedvoid
subtotal_minorintegerrequired
min 0 · max 9007199254740991
tax_minorintegerrequired
min 0 · max 9007199254740991
termsstring
max length 5000
total_minorintegerrequired
min 0 · max 9007199254740991
updated_atstring<date-time>required
versionintegerrequired
void_reasonstring | nullrequired
voided_atstring<date-time> | nullrequired
400Malformed request
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
401Authentication failed
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
403Permission denied
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
404Resource not found
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
409Request conflict
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
413Request body is too large
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
415Unsupported media type
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
422Request validation failed
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
500Unexpected server error
errorobjectrequired
Show properties
codestringrequired
detailsobject[]
Show properties
Array of object
messagestringrequired
pathstringrequired
messagestringrequired
request_idstringrequired
Request
curl -X POST "/v1/companies/497f6eca-6276-4993-bfeb-53cbbbba6f08/invoices" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "idempotency-key: stringst" \
  -H "Content-Type: application/json" \
  -d '{
  "currency": "string",
  "customer_id": "160c0c4b-9966-4dc1-a916-8407eb10d74e",
  "due_date": "2019-08-24",
  "external_reference": "string",
  "issue_date": "2019-08-24",
  "language": "string",
  "lines": [
    {
      "description": "string",
      "quantity": "string",
      "tax_rate_bps": 10000,
      "unit": "string",
      "unit_amount_minor": 9007199254740991
    }
  ],
  "notes": "string",
  "purchase_order_reference": "string",
  "terms": "string"
}'
Response
{
  "company_id": "b2e6a1c3-1a5e-44ae-a8fd-81f76fd715cf",
  "created_at": "2019-08-24T14:15:22Z",
  "currency": "string",
  "customer": {
    "address": {
      "city": "string",
      "country_code": "string",
      "line_1": "string",
      "line_2": "string",
      "postal_code": "string",
      "region": "string"
    },
    "email": "user@example.com",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "identifiers": [],
    "name": "string",
    "schema_version": 0
  },
  "customer_id": "160c0c4b-9966-4dc1-a916-8407eb10d74e",
  "customer_name": "string",
  "due_date": "2019-08-24",
  "external_reference": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "issue_date": "2019-08-24",
  "issued_at": "2019-08-24T14:15:22Z",
  "issuer": {
    "address": {
      "city": "string",
      "country_code": "string",
      "line_1": "string",
      "line_2": "string",
      "postal_code": "string",
      "region": "string"
    },
    "email": "user@example.com",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "identifiers": [],
    "legal_name": "string",
    "schema_version": 0,
    "trading_name": "string"
  },
  "language": "string",
  "lines": [
    {
      "description": "string",
      "net_amount_minor": 9007199254740991,
      "position": 0,
      "quantity": "string",
      "tax_amount_minor": 9007199254740991,
      "tax_rate_bps": 10000,
      "total_amount_minor": 9007199254740991,
      "unit": "string",
      "unit_amount_minor": 9007199254740991
    }
  ],
  "notes": "string",
  "number": "string",
  "purchase_order_reference": "string",
  "status": "draft",
  "subtotal_minor": 9007199254740991,
  "tax_minor": 9007199254740991,
  "terms": "string",
  "total_minor": 9007199254740991,
  "updated_at": "2019-08-24T14:15:22Z",
  "version": 0,
  "void_reason": "string",
  "voided_at": "2019-08-24T14:15:22Z"
}