curl --request POST \
--url https://api.upstackdata.com/accounts/api/costs/lines \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"costType": "variable",
"line": {
"name": "Google Ads — % of spend",
"type": "pct_ad_spend",
"percentRate": 2,
"category": "marketing",
"channel": "online",
"currency": "USD"
}
}
'{
"config": {}
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}Add a cost line
Add a new cost line for one of the five line-typed cost surfaces
— order, gateway, shipping (profile rule), variable, or
fixed. The server assigns a ULID for the new line.
The line body is discriminated by costType — see the
per-type schemas (OrderCostLine, GatewayCostLine,
ShippingProfileCostLine, VariableCostLine, FixedCostLine)
for the shape required by each.
Triggers a per-order COGS recalculation downstream — except for
variable and fixed, which apply at aggregate report time and
do not require per-order recalc.
Required scope: costs:write.
curl --request POST \
--url https://api.upstackdata.com/accounts/api/costs/lines \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"costType": "variable",
"line": {
"name": "Google Ads — % of spend",
"type": "pct_ad_spend",
"percentRate": 2,
"category": "marketing",
"channel": "online",
"currency": "USD"
}
}
'{
"config": {}
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}{
"message": "<string>",
"errors": [
{
"message": "<string>",
"key": "<string>",
"path": [
"<string>"
]
}
]
}Authorizations
Your Upstack API key. Starts with upstack_.
The pixel id the request targets.
Body
line shape is discriminated by costType — the listed schemas
for each cost type are validated server-side. Sending an
OrderCostLine shape with costType=variable is rejected with 400.
The five cost-line surfaces. Each value selects the corresponding
line shape in the line (POST) or updates (PUT) field of the
request body.
order, gateway, shipping, variable, fixed One of the per-type line shapes, selected by costType.
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
Response
The updated cost config (with the new line appended).
Was this page helpful?