Docs / Platform / How-to

API access for developers

Create API keys and manage agents and calls programmatically over a REST API.

How do I get an API key?

  1. Open Settings and find the API Access section.
  2. Create a key: give it a name and pick its scopes - agents:read, agents:write, agents:publish, agents:test, calls:read, contacts:read, contacts:write, channels:messages, conversations:read, conversations:write, automations:read, automations:write, templates:read.
  3. Copy the key immediately. It is shown once at creation and never again; only a hash is stored. Keys can be revoked at any time from the same page.

How do I authenticate?

Send the key as a bearer token on every request. The base URL is https://app.workflowhq.co/api/v1.

curl https://app.workflowhq.co/api/v1/agents \
  -H "Authorization: Bearer YOUR_API_KEY"

What endpoints are available?

  • GET /agents - list your agents (paginated with page and limit).
  • POST /agents - create an agent. Supports an idempotency key so safe retries never create duplicates.
  • GET /agents/{id} - fetch one agent's full configuration.
  • PUT /agents/{id} - update the draft: name, voice, systemPrompt, languages, timezone, transfer destinations, agent transfers.
  • POST /agents/{id}/publish - publish the draft so live traffic picks it up.
  • POST /agents/{id}/test-call - start a test web call for the agent (limited to 5 per hour).
  • GET /calls/{id} - fetch a call record: transcript, duration, outcome, analysis, extracted fields.
  • POST /contacts - create or update contacts (upsert matched on email, then phone; batch up to 100). Returns the contact id either way.
  • GET /contacts - search by email, phone or tag, paginated with limit and offset.
  • GET /contacts/fields - the exact field keys your account accepts: the standard columns plus your own custom fields with types and dropdown options.
  • PATCH /contacts/{id} - update only the fields you send; use this when the email or phone itself is changing.
  • POST /contacts/{id}/notes - attach free text to a contact, for example a form answer or a post you scraped.
  • Do-not-contact: contacts carry a dnd object, one true or false per channel (sms, email, whatsapp, calls, social). Send dnd on POST or PATCH to opt someone out or back in; channels you leave out are unchanged.
  • POST /contacts/{id}/tags - add tags without resending the record; existing tags survive, duplicates are ignored. DELETE /contacts/{id}/tags removes the named ones. Both are idempotent, so retries are safe.
  • GET /conversations - every conversation in your Inbox, newest activity first, on all channels: web chat, email, SMS, WhatsApp, Instagram, Messenger and API channels.
  • GET /conversations/{id}/messages - one conversation's full message history.
  • POST /conversations/{id}/messages - reply in a conversation. It goes out on whatever channel that conversation is on; you never name a channel or a phone number.
  • POST /messages - send one approved WhatsApp template straight away, with that message's own values, and get its message id back.
  • GET /messages and GET /messages/{id} - did it arrive? Sent, delivered, read or failed, with the reason. Filter by automation run, workflow, contact or time.
  • GET /templates - your saved message templates, including each WhatsApp template's approval status per number and the order of its variables.
  • POST /channels/{id}/messages - send a message into an API channel (see the API channel page under Integrations).
  • Prefer a ready-made website bubble? Create a Web chat widget under Settings, Integrations, Channels: you get a one-line script keyed to the widget, pick an agent to answer or none so your team replies from the Inbox, and change who answers any time without touching the site. Human-only conversations use no AI chats; an agent answering bills from your quota as usual.

How do contact upserts behave?

POST /contacts matches on email first, then phone. If a contact exists, the fields you send are merged onto it and absent fields are never blanked, so a partial payload cannot wipe data someone typed in the dashboard. If nothing matches, the contact is created. Retrying the same request is safe: it lands on the same record. Custom field values go in a custom object keyed by field key; unknown keys are rejected by name, and GET /contacts/fields tells you the keys that exist.

A first name alone is a valid contact, same rule as the dashboard. But with no email or phone there is nothing to match on, so such a request always creates - retrying it creates again. Include an email or phone whenever you mean update-or-create.

Phone numbers are stored in international form. If your account is set to India, a bare 10-digit number such as 9876543210 is saved as +919876543210, so WhatsApp and calls reach it; numbers that already carry a country code are kept as sent. Values are checked against each field's type: email fields must hold a valid address, url fields must start with http or https, and a multi-select value is sent as a JSON array - "interests": ["Gold", "VIP"] - or as a comma-separated string; both are stored the same way. A rejected value names the field and the rule, so the fix is always visible in the error.

Tags are free strings created on the fly - write signal:hiring and the tag now exists, nothing is pre-registered. One rule to know: tags in a create or update payload REPLACE the contact's whole tag list. To add tags in the same call without touching the rest, send them as addTags instead (for example "addTags": ["abandoned-cart"]); existing tags survive and duplicates are ignored. The tags endpoints do the same for a contact you already have the id of.

curl -X POST https://app.workflowhq.co/api/v1/contacts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Asha Rao",
    "email": "asha@example.com",
    "phone": "+919876543210",
    "tags": ["webinar-lead"],
    "custom": { "company": "Acme Traders" }
  }'

How do drafts and publishing work over the API?

Exactly like the dashboard: PUT edits the draft, and live phone calls and widgets keep running the last published version until you POST /publish. Every save is versioned, so changes made over the API appear in the agent's version history and can be reverted from the dashboard.

What do errors look like?

Errors return a JSON body of the shape { "error": { "code": "...", "message": "..." } } with a matching HTTP status: 401 for a missing or invalid key, 403 for a key without the required scope, 404 for a resource that doesn't exist in your organization, 422 for validation errors, and 429 when rate-limited.

Are there rate limits?

Yes, two per API key: 100 requests every 10 seconds, and 200,000 requests a day. Each key has its own allowance, so one integration can never use up another's. The limits apply to every endpoint under /api/v1 and to the MCP server.

Every response tells you where you stand. X-RateLimit-Max and X-RateLimit-Remaining cover the 10-second window, and X-RateLimit-Limit-Daily and X-RateLimit-Daily-Remaining cover the day. Read these rather than counting requests yourself.

Go over and you get a 429 with the code RATE_LIMITED and a Retry-After header holding the number of seconds to wait. Wait that long, then send the same request again. A loop that reads many pages should pause between calls: about one request a second is always safe.

There is also a ceiling on requests from a single network address, set well above one key's limit. Normal use never reaches it; it exists to stop floods.

HTTP/1.1 429 Too Many Requests
Retry-After: 4
X-RateLimit-Max: 100
X-RateLimit-Remaining: 0

{ "error": { "code": "RATE_LIMITED", "message": "Too many requests. This API key allows 100 requests every 10 seconds. Try again in 4 seconds." } }

Can I create workflows over the API?

Yes. GET /api/v1/automations lists your workflows, POST creates one (from a template key or a full definition in the same format the builder uses), GET /api/v1/automations/{id} returns the definition with recent runs, and PATCH edits, renames or changes status. Requires an API key with the automations read and write scopes.

Two safety rules are built in: a created workflow is always a draft, and going live is a separate PATCH that must pass the same readiness checks as the dashboard toggle. And there is no delete over the API at all: keys and AI agents can create, update and pause, while deleting anything remains a signed-in dashboard action.

Can I read and reply to conversations?

Yes, on every channel through one pair of endpoints. GET /conversations lists your Inbox threads and GET /conversations/{id}/messages returns one thread's full history. Each message carries a role: user is the customer, assistant is your AI agent, and teammate is a person - whether they typed it in the Inbox or sent it through this API. Filter the list with channel (a comma-separated list of web, email, sms, whatsapp, instagram, messenger, api), status (open or resolved), contactId, limit (up to 200) and since. The response includes a now timestamp; pass it back as since next time to poll for what moved.

To read further back than one page, use the cursor. Each response carries nextCursor: send it back as cursor, with the same filters, to get the next older page, and stop when nextCursor comes back null. Three more filters narrow the list: before (an ISO time) returns conversations last active earlier than that moment, lastRole=user returns only the ones where the customer spoke last and is waiting on a reply, and q matches the visitor's name, the contact's name or their Instagram handle. A conversation that receives a new message while you are paging moves to the top, so it will not reappear on an older page; your next since poll picks it up.

POST /conversations/{id}/messages sends a reply. You do not choose a channel: the conversation already knows whether it is a WhatsApp chat, an email thread or your website widget, and the reply goes out the same way, appears in the Inbox as a teammate message, and is logged exactly like one sent by hand. Needs the conversations:write scope; reading needs conversations:read.

Send plain text as { "message": "..." }. On WhatsApp you can also send an approved template with { "templateId": "..." }, which is the only way to reach someone whose 24-hour window has closed - a free-text reply after that is refused up front rather than quietly dropped by WhatsApp. Files, contact cards and payment requests are Inbox-only, because they need an upload or your payment settings.

A conversation you have already resolved returns 409: reopen it in the Inbox first. Opt-outs still apply, and a reply that the channel refuses comes back as a 422 with the provider's reason in plain words, so a message is never shown as sent when it did not go out.

# every conversation touched since your last poll
curl "https://app.workflowhq.co/api/v1/conversations?since=2026-11-04T10:00:00Z" \
  -H "Authorization: Bearer YOUR_API_KEY"

# everyone waiting on a reply, 200 at a time - repeat with the returned nextCursor until it is null
curl "https://app.workflowhq.co/api/v1/conversations?lastRole=user&limit=200&cursor=NEXT_CURSOR" \
  -H "Authorization: Bearer YOUR_API_KEY"

# reply in one - the channel is whatever the conversation is on
curl -X POST https://app.workflowhq.co/api/v1/conversations/CONVERSATION_ID/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "message": "Thanks! Sending your report now." }'

Did my message arrive? (delivery status)

GET /messages/{id} tells you what happened to one message you sent: sent, delivered, read or failed, with the provider's own reason in error when something went wrong. The id is either the one WorkflowHQ returned when you sent it, or the provider's own (a WhatsApp wamid, a Twilio SID) - whichever you kept.

GET /messages lists them, newest first. Filter with runId to see exactly what one automation run sent, automationId for everything a workflow has sent, contactId for one person, plus since and limit (up to 200). Like the conversations list it returns a now timestamp to pass back as since on your next poll.

Delivery is not instant news: a WhatsApp message is sent the moment it leaves, then turns delivered and read as the phone reports back, usually within seconds. A message that leaves fine but is refused later shows as failed with the reason, for example a number that has blocked you or a quality limit. Needs the conversations:read scope.

curl https://app.workflowhq.co/api/v1/messages/MESSAGE_ID \
  -H "Authorization: Bearer YOUR_API_KEY"

# everything one automation run sent
curl "https://app.workflowhq.co/api/v1/messages?runId=RUN_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"

Can I send a WhatsApp template with my own values?

Yes. POST /messages sends one approved WhatsApp template to one contact straight away and returns the message id, so you can check delivery afterwards. Name the person with contactId or phone, the template with templateId or templateName, and pass that message's values in variables.

The values in variables fill the template's placeholders for that one send only. They are used instead of the contact's saved fields while the message is built, and nothing is written to the contact. That matters when the same person gets several messages in a row: send three reports and each one carries its own link, instead of each overwriting the field the one before it used.

A template whose header is a document can carry this recipient's own file with headerDocument: { url, filename }. Opt-outs, the template's approval on your number and the usual refusals all still apply, and a refusal comes back as a 422 with the reason in plain words rather than a message that quietly never arrives. Needs the conversations:write scope.

curl -X POST https://app.workflowhq.co/api/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+919876543210",
    "templateName": "report_ready_link",
    "variables": {
      "report_name": "Name Correction Report",
      "report_link": "https://example.com/r/abc123"
    }
  }'

Can AI assistants use my CRM directly (MCP)?

Yes. WorkflowHQ speaks MCP (Model Context Protocol), so AI tools such as Claude Code, Claude Desktop or Cursor can search your contacts, add or update them, tag them and save notes, using the same API key and permissions as the REST API. A common use: paste a LinkedIn conversation into your AI assistant and say 'save this person to my CRM with the context'.

Connect it with your MCP client's remote server option: URL https://app.workflowhq.co/api/mcp, with an Authorization: Bearer header carrying an API key that has the contacts read and write scopes. The assistant then sees six tools covering search, create or update, notes, tags and field discovery. Everything an assistant writes follows the same rules as the API: matching by email or phone updates the existing contact, and unknown custom fields are rejected.

Still stuck? Email hello@workflowhq.co - a real person replies, usually within a few hours.