Skip to content

Add a line item to an estimate

POST
/estimates/{id}/line-items
Code sample: Shell / cURL
curl --request POST \
--url https://example.com/api/v1/estimates/example/line-items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "description": "example", "discountPercent": 1, "kind": "example", "orderId": "example", "position": 1, "quantity": 1, "rate": 1 }'

Adds a line item to a DRAFT estimate and recalculates its totals. discountPercent takes a percentage off quantity times rate (the line’s amount is net of it) and is refused with 409 DISCOUNT_CONFLICT while the estimate has an estimate-wide discount. Requires the estimates.manage permission.

id
required

Resource identifier (CUID2).

string
>= 1 characters

Resource identifier (CUID2).

Media typeapplication/json
object
description
required
string
>= 1 characters
discountPercent

Percentage taken off quantity times rate on this line, above 0 and below 100 (two decimals); amount is net of it. Null removes it. A line discount and the estimate-wide discount never combine: sending one while the other is set is refused with 409 DISCOUNT_CONFLICT.

Any of:
number
> 0 < 100
kind
string
orderId
string
position
integer
>= -9007199254740991 <= 9007199254740991
quantity
required
number
> 0
rate
required
number

Example generated

{
"description": "example",
"discountPercent": 1,
"kind": "example",
"orderId": "example",
"position": 1,
"quantity": 1,
"rate": 1
}

The created line item.

Media typeapplication/json
object
data
required

A line item on an estimate.

object
amount
required

Quantity times rate less discountPercent, rounded to the cent.

number
description
required
string
discountPercent
required

Percentage taken off quantity times rate on this line; null for none. Never set on an estimate with an estimate-wide discount.

number | null
estimateId
required
string
id
required
string
kind
required
string | null
orderId
required
string | null
position
required
integer
>= -9007199254740991 <= 9007199254740991
quantity
required
number
rate
required
number

Example generated

{
"data": {
"amount": 1,
"description": "example",
"discountPercent": 1,
"estimateId": "example",
"id": "example",
"kind": "example",
"orderId": "example",
"position": 1,
"quantity": 1,
"rate": 1
}
}

Validation error. Parse failures include field paths and expectations.

Media typeapplication/json

Validation error with safe field paths and expected values; submitted values are never returned.

object
error
required
object
code
required

Stable machine-readable error code.

string
issues
Array<object>
object
expected
required
string
message
required
string
path
required
Array<string | number>
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Unauthorized.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Forbidden.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Not found.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

A discountPercent was sent while the estimate has an estimate-wide discount (DISCOUNT_CONFLICT).

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Line items can only be added to DRAFT estimates.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}

Rate limit exceeded. Wait for Retry-After before retrying.

Media typeapplication/json

Standard error envelope.

object
error
required
object
code
required

Stable machine-readable error code.

string
message
required

Human-readable error message.

string
status
required

HTTP status code, mirrored in the body.

integer
>= -9007199254740991 <= 9007199254740991

Example

{
"error": {
"code": "UNAUTHORIZED"
}
}
RateLimit-Limit
string
/^\d+$/

Maximum requests in the current quota window.

RateLimit-Policy
string

Quota policy in requests and window seconds, for example 60;w=60.

RateLimit-Remaining
string
/^\d+$/

Requests left in this quota window (zero when blocked).

RateLimit-Reset
string
/^\d+$/

Seconds until the current quota window resets, when available from the rate-limit store.

Retry-After
string
/^\d+$/

Seconds until another request may be attempted.