Create invoice milestones in bulk

Operation ID: bulkCreateInvoiceMilestones

Group: Accounting › Invoice Milestones

Open in the interactive reference

POST /accounting/invoice-milestones/bulk

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Creates invoice milestones, all or nothing. Each row names its sales order and the Milestone-invoiced product lines it bills; its amount is spread over those lines in proportion to their totals.

After the call, each sales order's milestones must cover the full amount of every product line they bill, so create all of an order's milestones in one call. The milestones an order already has are kept and count towards that total.

New milestones are open. Release one for invoicing with POST accounting/invoice-milestones/:id/release.

The response lists the new ids in the order of the rows.

Parameters

Name In Type Required Description
Api-Version header string · v1 yes The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version v1.
Idempotency-Key header string no An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with 400 IDEMPOTENCY_NOT_SUPPORTED rather than silently ignored.

Request body

Required, application/json: bulkCreateInvoiceMilestonesInput.

Field Type Required Description
invoiceMilestones array<object> yes The milestones to create. If any row is invalid, or an order's milestones would not add up, nothing is created. Example: [{"salesOrderId":"0e6a7c15-93d2-4b48-8f61-2c5b9a3d7e10","description":"Kick-off","orderSequence":1,"percentage":"60","projectedDate":"2026-11-15","amount":"6000.00","salesOrderProductLineIds":["9d1f6b34-2e7a-4c58-b0a9-71c3e5f28d46"]},{"salesOrderId":"0e6a7c15-93d2-4b48-8f61-2c5b9a3d7e10","description":"Go-live","orderSequence":2,"percentage":"40","projectedDate":"2026-12-01","amount":"4000.00","salesOrderProductLineIds":["9d1f6b34-2e7a-4c58-b0a9-71c3e5f28d46"]}].
invoiceMilestones[].salesOrderId string yes The sales order whose product lines the milestone bills.
invoiceMilestones[].description string no What the milestone stands for, as it appears on the invoice line.
invoiceMilestones[].orderSequence number no The milestone's position among the sales order's milestones.
invoiceMilestones[].percentage decimal no The share of the sales order the milestone bills, in percent. A number, not an amount; it is stored as given.
invoiceMilestones[].projectedDate date no When the milestone is expected to be reached. Format YYYY-MM-DD.
invoiceMilestones[].amount decimal yes The amount the milestone bills, in the sales order currency. Must be greater than zero.
invoiceMilestones[].salesOrderProductLineIds array<string> yes The Milestone-invoiced product lines of the sales order the milestone bills. At least one.
{
  "invoiceMilestones": [
    {
      "salesOrderId": "0e6a7c15-93d2-4b48-8f61-2c5b9a3d7e10",
      "description": "Kick-off",
      "orderSequence": 1,
      "percentage": "60",
      "projectedDate": "2026-11-15",
      "amount": "6000.00",
      "salesOrderProductLineIds": [
        "9d1f6b34-2e7a-4c58-b0a9-71c3e5f28d46"
      ]
    },
    {
      "salesOrderId": "0e6a7c15-93d2-4b48-8f61-2c5b9a3d7e10",
      "description": "Go-live",
      "orderSequence": 2,
      "percentage": "40",
      "projectedDate": "2026-12-01",
      "amount": "4000.00",
      "salesOrderProductLineIds": [
        "9d1f6b34-2e7a-4c58-b0a9-71c3e5f28d46"
      ]
    }
  ]
}

Response

200 Success

Under data (bulkCreateInvoiceMilestonesOutput):

Field Type Required Description
created array<object> yes The created milestones, in the same order as the input. Match rows to inputs by index. Example: [{"id":"4b8f2d61-0c3e-4f7a-9a15-6e2d8c90b7a4"},{"id":"7a1c3e95-5d20-4b6f-8e34-0f9b2d6c1a87"}].
created[].id string yes The unique identifier for the created invoice milestone.
{
  "data": {
    "created": [
      {
        "id": "4b8f2d61-0c3e-4f7a-9a15-6e2d8c90b7a4"
      },
      {
        "id": "7a1c3e95-5d20-4b6f-8e34-0f9b2d6c1a87"
      }
    ]
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}

Response headers

Errors

Code Status
SALES_ORDER_NOT_FOUND 400
PRODUCT_LINE_NOT_FOUND 400
PRODUCT_LINE_NOT_MILESTONE_BILLED 400
NO_MILESTONES 400
INVALID_AMOUNT 400
NO_PRODUCT_LINES 400
SALES_ORDER_NOT_EDITABLE 400
MILESTONES_NOT_FULLY_ALLOCATED 400
IDEMPOTENCY_KEY_CONFLICT 409
IDEMPOTENCY_PAYLOAD_MISMATCH 422

Statuses