Draft an invoice from Claude Code
Create a Read and draft key for one business, put it in an environment variable, and add Billr with claude mcp add --transport http and an Authorization header that references the variable. Confirm the connection with a read-only request, then ask for a draft. Billr always creates a draft; you check client, business, currency and amount, and sending is a separate action that a Read and draft key cannot take.
Written and reviewed by the Billr team. Published , last reviewed .
- Who this is for
- People who already work inside Claude Code and want the invoice to come out of the same session.
- Billr capabilities used
list_clientslist_unbilledcreate_invoice
What you need first
- A Billr account with at least one client. You can create the client in the dashboard, or let the session create it later with
create_client. - On hosted Billr, a business with an active trial or subscription. Drafting is a write, and writes are refused for a business without one; reads keep working. Each account gets one 14-day trial from signup, and each business then needs its own subscription.
- Claude Code installed and able to run the
claudecommand. - An API key with the Read and draft profile, limited to the business you invoice from. That profile reads and drafts, which is everything this guide needs. It cannot send an invoice to a client.
Set it up
01Create a scoped key in Billr
Open Agents → API Keys and create a key. Give it a label you will recognize, pick the business under Business rather than leaving All businesses, and keep Read and draft (recommended) under Agent permissions. The key is shown once, so copy it before you close the dialog.
New keys expire 90 days after you create them, and the key list shows each key's expiry date. You can revoke a key there at any time. More detail in API keys and scopes.
02Put the key in an environment variable
Do not paste the key into a command line, where it is saved to your shell history. In bash or zsh, read it without echoing it:
read -rs BILLR_API_KEY && export BILLR_API_KEYPaste the key and press Enter. Nothing is printed, and the variable lasts only for this terminal. Use a name of your own such as
BILLR_API_KEY: Claude Code's MCP documentation says it reads its own and your cloud provider's credential variables as empty in remote server headers.03Add Billr as a remote HTTP server
Claude Code's MCP documentation recommends the HTTP transport for remote servers. For a setup only you use, run this in the same terminal:
claude mcp add --transport http billr https://mcp.billr.cc \ --header "Authorization: Bearer $BILLR_API_KEY"Your shell puts the key into the header, so the history records only the variable name. Claude Code then saves the server, header included, in your own
~/.claude.json. That is local scope: it loads in this project only. Add--scope userto load it in every project. AnAdded ...line means the configuration was written, not that the key works.For a team, commit a project
.mcp.jsonthat names the variable instead of the key. Claude Code expands variables inurlandheaderswhen it loads the file, so each person supplies their own key from the environment Claude Code starts in:{ "mcpServers": { "billr": { "type": "http", "url": "https://mcp.billr.cc", "headers": { "Authorization": "Bearer ${BILLR_API_KEY}" } } } }Claude Code asks for approval before it uses a server from a project
.mcp.jsonin an interactive session. If the variable is missing, the server still loads: Claude Code warns about the missing variable and sends the unexpanded text, which Billr rejects.04Check the configuration, then the connection
claude mcp list claude mcp get billr✔ Connectedmeans Claude Code reached Billr with a key Billr accepted, because Billr refuses every unauthenticated request. A failure status means it could not connect, and⏸ Pending approvalmeans a project server has not been approved yet, so nothing was checked. Inside a session,/mcpshows the server and its tools, which permission rules address asmcp__billr__<tool>. A tool list there can come from a cache, so treat the first tool call below as the real test.05Make a read-only request first
Start by asking for reads only. A successful response confirms the key works and shows you which business and clients the session can see:
List my Billr clients and tell me what is still unbilled.Claude Code may ask before it runs each Billr tool. That prompt is Claude Code's own control; keep it on. It does not change what the key may do in Billr.
06Then ask for the draft explicitly
Name the client, the work and the rate, and say clearly that this is a draft:
Draft an invoice for Harbor & Lane: 3 hours of consulting at $150 an hour. Leave it as a draft and show me the business, client, currency and total.
Worked example
Fictional account, field names as returned by the server
You say
Draft an invoice for Harbor & Lane: 3 hours of consulting at $150 an hour. Leave it as a draft and show me the business, client, currency and total.
Your agent calls
list_clients { "search": "Harbor" }create_invoice { "request_id": "4b9d2c68-1e5f-4a37-9c82-6d0b8f1a3e54", "client_name": "Harbor & Lane", "line_items": [ { "description": "Consulting", "quantity": 3, "rate": 150 } ] }
Illustrative response for a fictional account, abridged. It is not a recorded session; the field names are the ones create_invoice returns.
{
"summary": "Drafted INV-1147 for Harbor & Lane: $450.00",
"invoice": {
"id": "6b1f0c62-6a0f-4f38-9d0e-3a1f9a2b7c11",
"business_id": "e4c7a2d9-5b13-4f86-9a20-7d3e1b6c8f05",
"client_id": "9f2a4d18-3b7c-4a6e-8f0d-1c5b2e9a7d44",
"invoice_number": "INV-1147",
"status": "draft",
"issue_date": "2026-09-20",
"due_date": "2026-10-04",
"currency": "USD",
"subtotal": 450,
"discount_amount": 0,
"tax_amount": 0,
"shipping_amount": 0,
"total": 450,
"balance_due": 450,
"line_items": [
{
"description": "Consulting",
"quantity": 3,
"rate": 150,
"amount": 450
}
]
},
"linked_time_entry_ids": [],
"linked_expense_ids": [],
"public_url": "https://billr.cc/i/2cQ7f1RtKp",
"pdf_url": "https://billr.cc/api/public/invoices/2cQ7f1RtKp/pdf",
"app_url": "https://billr.cc/invoices/6b1f0c62-6a0f-4f38-9d0e-3a1f9a2b7c11"
}Review the draft, then send it separately
Open the draft from app_url and check four things yourself: the client, the business it was created under (business_id), the currency and the amount. Correct a draft with Correct a draft invoice.
Sending is a separate action. You can send from Billr, or from an agent whose key has the Billing or Full profile. With a Read and draft key, send_invoice is not offered to the session at all. Approving a Claude Code tool prompt does not add that permission. With a key that can send, approving send_invoice emails the client immediately, and Billr asks for no further confirmation. Task pricing and task invoice approval have separate mandatory human approval steps in Billr.
What this flow does not do
create_invoicealways returns a draft. Nothing is emailed to your client, and no payment link is sent, until someone sends it.- Currency follows the client. Source work recorded in another currency is not converted, so the amounts have to line up before you invoice.
- A draft keeps its number when you edit it; cancelling and creating a replacement produces a new number. Read Find unbilled work before you let an agent bill from logged time, because attached work cannot be unlinked again while the invoice exists.
- Billing a client for the AI usage behind the work is a separate decision. See How to bill clients for AI usage.
- Billr also supports browser sign-in for MCP clients, set up from Connect your agent. This guide covers only the scoped API key.
Troubleshooting
- claude mcp list shows ✘ Failed to connect
- Billr answers 401 to every request when the key is expired, revoked, mistyped or empty, including the first connection. Because you configured the header yourself, Claude Code reports a failed connection rather than offering a sign-in. Check the key's expiry in Agents → API Keys, create a new key if needed, then run claude mcp remove billr and add it again. The hosted endpoint is https://mcp.billr.cc; self-hosted, it is your own origin plus /api/mcp.
- A missing-variable warning for BILLR_API_KEY
- The variable is not set in the environment Claude Code started from. Claude Code started from a desktop app or an IDE may not see variables exported in a terminal. Set the variable where Claude Code is launched and restart it, or use the local-scope command, which stores the key in your own configuration.
- send_invoice, payments or delete tools are missing
- Billr only offers the tools the key allows. Read and draft has no send, payment or delete tools. Keep it that way for this guide; create a separate Billing key only when you decide an agent should send.
- A draft is refused with plan_required
- This business has no active hosted trial or subscription. Reads still work; drafting and other writes do not. Check the business in Billing.
- "Multiple businesses in scope … pass business_id"
- The key was created for All businesses and you belong to more than one. Create a key for the one business you invoice from, or tell the agent which business_id to use.
- The session cannot find the client you meant
- client_name has to match the stored name exactly, ignoring case, in the business the key reaches. Ask the agent to run list_clients with a search term first, or pass the client id from the dashboard URL.
- Two invoices appear after one retry
- create_invoice is idempotent on request_id. If your agent retries after a timeout, it has to reuse the same request_id with the same input to get the original draft back instead of a second one.
Sources
- Claude Code MCP documentation
- Claude Code permissions and tool names
- Billr: connect your agent
- Billr: API keys and scopes
Reviewed 2026-10-15 against Billr's own tool implementations and the client documentation linked above.
Read next
You need a Billr account and one client before the session can draft anything. Hosted accounts get one 14-day trial from signup (each business then needs its own subscription), and the first client is created from the dashboard or by the agent.
Create an account