Skip to content

Make your first API call

Create an API key, find a customer and send them a WhatsApp message from your own code, in about 10 minutes.

10 minutesDevelopersUpdated

By the end of this tutorial you’ll have an API key, you’ll have found a customer with the API, and you’ll have sent them a WhatsApp message from your own code. The examples send Priya Sharma an update about her order.

  • A Soosh workspace with a WhatsApp number connected, where you’re the owner or an admin
  • A plan that includes the Messages API and the Contacts API
  • A customer who has messaged your number in the last 24 hours (you can send them anything for 24 hours after their last message)
  • A terminal with curl, or Node.js 18 or later, or Python 3 with requests

An API key lets your code use your workspace, but only for what you allow it. It belongs to the workspace, so it keeps working if you leave.

  1. In Soosh, go to Settings > API keys (opens Soosh in a new tab) and click Create API key.
  2. In Name, enter where the key will be used, like Order system.
  3. Under What this key can do, tick Send messages, upload media and Read messages and media under Messages.
  4. Under Contacts, tick List and read contacts.
  5. Click Create key.
  6. Click Copy key, then Done. (If you copy the key another way, tick I’ve copied the key instead.)

The key starts with soosh_live_. Copy it now: Soosh shows it only once.

In your terminal, keep the key in a variable so it isn’t typed into every command:

Terminal window
export SOOSH_API_KEY="soosh_live_paste_your_key_here"

Every request goes to https://app.soosh.io/v1/ with your key in the Authorization header (see Authentication). List contacts finds Priya by her phone number:

Terminal window
curl "https://app.soosh.io/v1/contacts?phone=%2B919876543210" \
-H "Authorization: Bearer $SOOSH_API_KEY"

You get back the contact with that number:

{
"data": [
{
"id": "4ea0d485-435d-407f-837a-c7d67095f23a",
"phone": "+919876543210",
"name": "Priya Sharma",
"whatsapp_name": "Priya",
"tags": ["VIP"],
"marketing_opt_out": false,
"number_id": "0f6d3c1e-5b7a-4c52-9a55-3f6a2d5c8b10",
"chat": {
"status": "open",
"assigned_agent_id": null,
"last_message_at": "2026-10-15T09:12:40.118Z",
"last_inbound_at": "2026-10-15T09:12:40.118Z"
}
}
],
"next_cursor": null
}

(Some fields are left out here.) Copy Priya’s id; the next request uses it. last_inbound_at is when she last wrote.

Send Priya a text message with Send a message. In each example, replace 4ea0d485-… with the id you copied:

Terminal window
CONTACT_ID="4ea0d485-435d-407f-837a-c7d67095f23a"
curl https://app.soosh.io/v1/messages \
-H "Authorization: Bearer $SOOSH_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"contact_id\": \"$CONTACT_ID\", \"type\": \"text\", \"text\": {\"body\": \"Good news, Priya. Your peacock blue saree has shipped and arrives by Friday.\"}}"

Soosh answers 201 straight away, before WhatsApp has the message, so the Message has the status pending:

{
"id": "7c678987-a6fa-4a6e-b333-c57204c43eb7",
"contact_id": "4ea0d485-435d-407f-837a-c7d67095f23a",
"direction": "outgoing",
"type": "text",
"status": "pending",
"text": { "body": "Good news, Priya. Your peacock blue saree has shipped and arrives by Friday." },
"sent_by": { "type": "api_key", "id": "5e1d2c3b-4a59-4f68-8e7d-6c5b4a392817", "name": "Order system" },
"error": null
}

(Some fields are left out here.) If you get 422 window_closed instead, Priya hasn’t written to you in the last 24 hours, and you need a template. See Send a template.

Get a message by its id:

Terminal window
curl https://app.soosh.io/v1/messages/7c678987-a6fa-4a6e-b333-c57204c43eb7 \
-H "Authorization: Bearer $SOOSH_API_KEY"

Its status is now sent, and becomes delivered and then read as Priya’s phone receives and opens it. If it says failed, error.message says why.

The message also appears in Priya’s chat in the Soosh inbox, sent by API · Order system. A text, media or button message from a key reopens the chat if it was closed, as a reply from your team does. A template doesn’t.

  • An API key belongs to the workspace, does only what you tick, and is shown once.
  • Every request sends the key as Authorization: Bearer … to https://app.soosh.io/v1/.
  • GET /v1/contacts?phone= finds a customer; their id addresses them in other requests.
  • POST /v1/messages sends a message, which starts as pending and moves to sent, delivered and read.