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.
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.
What you need
Section titled “What you need”- 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 withrequests
1. Create an API key
Section titled “1. Create an API key”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.
- In Soosh, go to Settings > API keys (opens Soosh in a new tab) and click Create API key.
- In Name, enter where the key will be used, like Order system.
- Under What this key can do, tick Send messages, upload media and Read messages and media under Messages.
- Under Contacts, tick List and read contacts.
- Click Create key.
- 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:
export SOOSH_API_KEY="soosh_live_paste_your_key_here"2. Find the customer
Section titled “2. Find the customer”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:
curl "https://app.soosh.io/v1/contacts?phone=%2B919876543210" \ -H "Authorization: Bearer $SOOSH_API_KEY"// find.mjs: run with node find.mjsconst res = await fetch('https://app.soosh.io/v1/contacts?phone=%2B919876543210', { headers: { Authorization: `Bearer ${process.env.SOOSH_API_KEY}` },});const { data } = await res.json();console.log(data);# find.py: run with python3 find.pyimport os, requests
res = requests.get( "https://app.soosh.io/v1/contacts", params={"phone": "+919876543210"}, headers={"Authorization": f"Bearer {os.environ['SOOSH_API_KEY']}"},)print(res.json()["data"])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.
3. Send the message
Section titled “3. Send the message”Send Priya a text message with
Send a message. In each example, replace 4ea0d485-… with the
id you copied:
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.\"}}"// send.mjs: run with node send.mjsconst res = await fetch('https://app.soosh.io/v1/messages', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SOOSH_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ contact_id: '4ea0d485-435d-407f-837a-c7d67095f23a', type: 'text', text: { body: 'Good news, Priya. Your peacock blue saree has shipped and arrives by Friday.' }, }),});console.log(res.status, await res.json());# send.py: run with python3 send.pyimport os, requests
res = requests.post( "https://app.soosh.io/v1/messages", headers={"Authorization": f"Bearer {os.environ['SOOSH_API_KEY']}"}, json={ "contact_id": "4ea0d485-435d-407f-837a-c7d67095f23a", "type": "text", "text": {"body": "Good news, Priya. Your peacock blue saree has shipped and arrives by Friday."}, },)print(res.status_code, res.json())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.
4. Check that it was sent
Section titled “4. Check that it was sent”Get a message by its id:
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.
What you’ve learned
Section titled “What you’ve learned”- An API key belongs to the workspace, does only what you tick, and is shown once.
- Every request sends the key as
Authorization: Bearer …tohttps://app.soosh.io/v1/. GET /v1/contacts?phone=finds a customer; theiridaddresses them in other requests.POST /v1/messagessends a message, which starts aspendingand moves tosent,deliveredandread.
Next steps
Section titled “Next steps”- Send a template, to message customers outside the 24-hour window
- Verify webhooks, to hear about replies and statuses instead of asking for them
- Handle errors and limits
- The API reference, for every endpoint and event
- Error codes, for what each one means