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": {
"pixelId": "<string>",
"costType": "global_product_override",
"createdAt": "<string>",
"updatedAt": "<string>",
"defaultCogs": 123,
"globalHandlingFee": 123,
"currency": "<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": {
"pixelId": "<string>",
"costType": "global_product_override",
"createdAt": "<string>",
"updatedAt": "<string>",
"defaultCogs": 123,
"globalHandlingFee": 123,
"currency": "<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
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.
Was this page helpful?