Create a project cost
In this lesson you will record a supplier bill as a cost on one of your projects. You will look up the four things a cost needs (a task, a supplier, a cost type and the bill’s lines), create the cost as a draft, and read it back.
You need a Drum account with at least one project and one supplier company, and a terminal with curl. It takes about 15 minutes. If you have not used the Drum API before, do Make your first API request first.
Check your token
You need an API token whose user’s role has these permissions:
api_readandapi_create, to read and create through the API.read_costsandcreate_costs, to list cost types and create the cost.read_companies, to find the supplier.- Read access to the project, for example
read_all_projects. view_project_metrics, to see the cost’s totals in the response. Without it the cost is still created, but the money fields are left out.
If you are not sure, ask an account admin, or see Record permissions. To make a token, follow Create an API token.
Save the token in your terminal, in place of YOUR_API_TOKEN:
export DRUM_API_TOKEN="YOUR_API_TOKEN"
Pick the project and task
Every cost sits on one task of a project. List a few projects:
curl -s -H "Authorization: Bearer $DRUM_API_TOKEN" \
"https://app.getdrum.com/api/v1/projects?items=5"
Note the id of the project the bill belongs to. Then read that project, replacing 20488 with your project’s id:
curl -s -H "Authorization: Bearer $DRUM_API_TOKEN" \
https://app.getdrum.com/api/v1/projects/20488
Look in deliverables for the task the bill is for:
"deliverables": [
{
"id": 7301,
"name": "Construction",
"tasks": [
{"id": 55120, "name": "Structural steel", "status": "in_progress"}
]
}
]
Note the task’s id. This is your task_id.
Find the supplier
Search the companies for the supplier by name. Replace steel with the start of your supplier’s name:
curl -s -H "Authorization: Bearer $DRUM_API_TOKEN" \
"https://app.getdrum.com/api/v1/companies?search=steel"
You should see the matching companies:
[
{
"id": 902,
"trading_name": "Northside Steel",
"company_type": "supplier",
"email": "accounts@northsidesteel.example"
}
]
Each company has more fields than shown here. Check that company_type is supplier or both, and note the id. This is your company_id.
You can add company_type=supplier to the search to list only suppliers, but that filter is an exact match: it leaves out companies marked both (a client and a supplier). Searching by name without it finds both kinds.
If you see {"error": "Forbidden"}, the token’s user does not have read_companies. If you see an empty array [], try a shorter search, or check the supplier’s name in Drum.
Choose a cost type
Cost types classify costs, such as subcontractors or materials. List them:
curl -s -H "Authorization: Bearer $DRUM_API_TOKEN" \
https://app.getdrum.com/api/v1/cost_types
[
{
"id": 610,
"name": "Subcontractor",
"code": "SUB",
"default": false,
"default_finance_account_id": 310
}
]
Pick the one that fits the bill and note its id. This is your cost_type_id. A cost always needs one, even when your account has a default.
Create the cost
You now have everything the cost needs. Replace the 20488 in the URL, and task_id, company_id and cost_type_id in the body, with your own values, and run:
curl -s -X POST \
-H "Authorization: Bearer $DRUM_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: tutorial-cost-1" \
https://app.getdrum.com/api/v1/projects/20488/costs \
-d '{
"cost": {
"task_id": 55120,
"company_id": 902,
"cost_type_id": 610,
"name": "Steel package",
"invoice_number": "INV-4471",
"issued_date": "2026-09-08",
"due_date": "2026-10-08",
"line_items": [
{"name": "Steel supply", "quantity": 2, "price_cents": 125000},
{"name": "Delivery", "quantity": 1, "price_cents": 15000}
]
}
}'
A few things to notice in this request:
- Money is in integer cents, before tax.
125000is 1,250.00. - Each line item has a
name, aquantityand aprice_centsper unit. Drum works out the cost’s total from its lines. - There is no
status, so the cost is created as adraft. A draft does not start your account’s cost approvals, which makes it safe to practise with. - The
Idempotency-Keyheader makes the request safe to retry. If your connection drops, send the same request with the same key, and Drum returns the first cost instead of creating a second one.
You should get the new cost back:
{
"id": 33910,
"name": "Steel package",
"invoice_number": "INV-4471",
"status": "draft",
"billable": "billable",
"project_id": 20488,
"task_id": 55120,
"cost_type_id": 610,
"company_id": 902,
"member_id": null,
"supplier_name": "Northside Steel",
"task_name": "Structural steel",
"cost_type_name": "Subcontractor",
"currency": "AUD",
"total_excluding_tax_cents": 265000,
"line_items": [
{"name": "Steel supply", "quantity": "2.0", "price_cents": 125000, "finance_account_name": "Subcontractors", "tax_rate_name": "GST on Expenses"},
{"name": "Delivery", "quantity": "1.0", "price_cents": 15000, "finance_account_name": "Subcontractors", "tax_rate_name": "GST on Expenses"}
]
}
Your cost has more fields than shown here. Check three things:
total_excluding_tax_centsis265000: two lots of 1,250.00 plus 150.00 delivery.total_centsadds the tax on each line.- Each line has a
finance_account_nameand atax_rate_name. You did not send them, so Drum filled them in, usually from the cost type’s default account and that account’s tax rate. To choose them yourself, sendfinance_account_idandtax_rate_idon each line. - Some cost types add a summary line with the project number. If yours does, you see one more line than you sent.
supplier_nameis your supplier.
Note the cost’s id.
If the request fails
The error body names the problem in code, and the input at fault in field:
{"error": "Task not found", "code": "task_not_found", "field": "task_id"}
code |
What to do |
|---|---|
task_not_found |
The task is not on this project. Read the project again and copy a task id from it |
company_not_found, cost_type_not_found |
Copy the id again from the list in the step above |
supplier_or_resource_required |
Send exactly one of company_id, member_id or new_supplier_name |
missing_input |
A required field is missing. field says which |
invalid_input |
A value could not be read. A line item field reads like line_items[0].price_cents |
A 403 with {"error": "Forbidden"} means the token’s user does not have create_costs. Nothing is saved when a request fails, so fix the request and send it again with a new Idempotency-Key.
The Costs reference lists every error.
Read the cost back
List the costs on the task with their lines, replacing the project and task ids:
curl -s -H "Authorization: Bearer $DRUM_API_TOKEN" \
"https://app.getdrum.com/api/v1/projects/20488/costs?task_id=55120&include_line_items=true"
Your new cost is in the list. You can also open the project in Drum and find it under the task, as a draft.
Clean up
You have recorded a supplier bill as a cost on a project task.
This cost was for practice. The API cannot delete a cost, so delete it in Drum: open the cost and select Delete Cost. This needs the delete_costs permission. If you do not have it, ask an account admin to delete the draft for you.
Next
- To record a real bill so it goes into your cost approvals, send
"status": "final". See Create a cost for every field, such as markups, purchase orders and billable status. - To attach the supplier’s PDF, see Attach a file.
- If the supplier is not in Drum yet, send
new_supplier_namein place ofcompany_id. Drum creates the supplier with the cost. This needscreate_companies. To keep suppliers in step with another system, see Sync companies and contacts from a CRM. - AI assistants connected to Drum can do the same with the
create_costMCP tool.