curl --request PUT \
--url https://api.upstackdata.com/accounts/api/costs/lines/{lineId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"costType": "variable",
"updates": {
"percentRate": 2.5
}
}
'{
"config": {
"pixelId": "5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71",
"costType": "variable",
"entries": [
{
"id": "01K6B2C4D6E8F0G2H4J6K8M0N2",
"name": "Agency fee, % of spend",
"type": "pct_ad_spend",
"percentRate": 2.5,
"category": "marketing",
"channel": "online",
"currency": "USD",
"createdAt": "2026-06-11T08:40:15.226Z",
"updatedAt": "2026-10-12T16:31:48.090Z"
}
],
"createdAt": "2026-06-11T08:40:15.226Z",
"updatedAt": "2026-10-12T16:31:48.090Z"
}
}{
"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>"
]
}
]
}COSTS
Update an order, payment, shipping, or recurring cost line
Change fields on an order fee, payment fee, shipping profile, variable cost, or recurring expense line by id. Fields you don’t send keep their values.
PUT
/
accounts
/
api
/
costs
/
lines
/
{lineId}
curl --request PUT \
--url https://api.upstackdata.com/accounts/api/costs/lines/{lineId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-pixel-id: <api-key>' \
--data '
{
"costType": "variable",
"updates": {
"percentRate": 2.5
}
}
'{
"config": {
"pixelId": "5f1e6a4f-2b7c-4d1e-9a3f-8c6b2e0d4a71",
"costType": "variable",
"entries": [
{
"id": "01K6B2C4D6E8F0G2H4J6K8M0N2",
"name": "Agency fee, % of spend",
"type": "pct_ad_spend",
"percentRate": 2.5,
"category": "marketing",
"channel": "online",
"currency": "USD",
"createdAt": "2026-06-11T08:40:15.226Z",
"updatedAt": "2026-10-12T16:31:48.090Z"
}
],
"createdAt": "2026-06-11T08:40:15.226Z",
"updatedAt": "2026-10-12T16:31:48.090Z"
}
}{
"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>"
]
}
]
}Required scope:
costs:write
Use this to correct a line, such as a mistyped gateway rate, or to end-date one. To
change a rate from a given date without rewriting older orders, set effectiveTo on
the current line here, then add the new rate with
Add a cost line.
Finding the line
- Take
lineIdfrom Get cost configuration:entries[].id, orprofiles[].idfor shipping profiles. costTypemust be the type the line belongs to. A mismatch returns404withCost line not foundorCost config not found for type.- Always send
updates. A body without it fails with500, not400.
How the merge works
- Fields in
updatesoverwrite the line’s values. Everything else is kept, along with the line’sidandcreatedAt.updatedAtis set to the time of the request. - A field that isn’t part of the line shape for
costTypereturns400. nullremoves a field, but only for the type-dependent amount fields and the effective dates. The schema forupdateslists them.- When you change an order line’s
typeor a shipping profile’srateType, send the amount fields the new type needs in the same request, andnullthe ones it doesn’t. Switching an order line to apct_*type needspercentRate; aper_*type needsflatAmount;by_order_weightneedsweightUnitandweightIntervals; the quantity types needquantityIntervals. A shipping profile switched toweight_tieredneedsweightUnitandweightTiers, and one switched toflatneedsflatAmount.
Recalculation
Changes toorder, gateway, and shipping lines recalculate the past orders they
affect. variable and fixed lines are applied when reports are built, so their
changes show up without a recalculation.
Related
- Delete a cost line to remove a line instead.
- Cost settings for what each line type does to contribution margin.
Authorizations
Path Parameters
Body
application/json
Partial update. Every field of the line shape for costType is optional in
updates. Fields you send are written and fields you leave out keep their value.
Send null to remove an amount field that no longer applies after a type change:
flatAmount, percentRate, weightUnit, weightIntervals, or quantityIntervals
on order lines, and flatAmount, weightUnit, or weightTiers on shipping
profiles. effectiveFrom and effectiveTo also accept null to clear the date.
null on any other field is rejected with 400.
Was this page helpful?