💬 Shared WhatsApp Inbox on the new PlatformMore
1msg official logo

Share courier contact card via WhatsApp API

This scenario sends a WhatsApp contact card with sendContact during the 24-hour customer service window after a driver or courier is assigned to the order.

Use case overview

This scenario sends a WhatsApp contact card with sendContact during the 24-hour customer service window after a driver or courier is assigned to the order.

Template example

Your courier contact for this delivery is in the card below.

WhatsApp Business API for courier or driver contact — share contact card

When to use it

Reach for this scenario when logistics assigns a driver or courier to an active delivery and the buyer needs that person's phone number without copying digits from a plain-text reply. It fits last-mile delivery teams sharing tap-to-save contacts inside an open order session and fleet operators handing off the assigned courier so the client can call directly from WhatsApp.

Fewer misdials
sendContact delivers a vCard with the courier display name and E.164 phone number, so the client taps to save or call instead of retyping digits that often get mistyped in chat.
Fewer repeat "driver number?" contacts
The intro line and contact card arrive in the same open WhatsApp session as the order, so the buyer gets direct phone access without opening email or calling support again.
No manual digit sharing
When logistics assigns the courier, your backend loads the display name and phone from the integration contract and sendContact fires automatically in the active session.
Contact stays in the order thread
The short message body points to the card below, so the courier details remain in the delivery chat the client already uses instead of a separate SMS or email thread.

Workflow

  1. Trigger

    Logistics assigns a driver or courier to the delivery.

    event · triggered

  2. Capture event

    Your backend loads the courier display name and phone number.

    phone: "+…"

  3. Build & send

    sendContact delivers the contact card in the active session.

    POST /send_contact

  4. Delivered

    The client saves or calls the courier from WhatsApp.

    delivered

WhatsApp Business API for courier or driver contact — share contact card

Technical implementation

Prerequisites

  1. 1MSG API Key · How to get API Key
  2. WhatsApp Business account · How to Connect WABA
  3. Open 24-hour session window · How the 24-hour window works
  4. Customer opt-in · How to Manage Customers Consent
  5. Webhook endpoint · How to Set Up Webhooks

Code examples

#!/usr/bin/env bash
set -euo pipefail

# === Configuration (replace "___" placeholders) ===
API_BASE_URL="https://api.1msg.io"        # production 1MSG API base URL
CHANNEL_ID="___"                           # channel ID from 1MSG dashboard
API_TOKEN="___"                            # channel JWT token (Bearer)



# === Test data ===
TEST_PHONE="___"                 # client phone in international format

PHONE_NORM="$(printf '%s' "$TEST_PHONE" | tr -cd '0-9')"
URL="${API_BASE_URL%/}/${CHANNEL_ID}/sendContact"

# specialist display name (code_contract)
# specialist phone in E.164 format
read -r -d '' PAYLOAD <<JSON || true
{
  "phone": "${PHONE_NORM}",
  "contacts": [
    {
      "name": { "formatted_name": "Иван Курьер", "first_name": "Иван Курьер" },
      "phones": [{ "phone": "+998901234567", "type": "CELL" }]
    }
  ]
}
JSON

RESPONSE="$(curl -s -w '\n%{http_code}' -X POST "$URL" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -d "$PAYLOAD")"

HTTP_CODE="$(printf '%s' "$RESPONSE" | tail -n1)"
BODY="$(printf '%s' "$RESPONSE" | sed '$d')"

case "$BODY" in
  *'"sent":true'*) ok=1 ;;
  *) ok=0 ;;
esac

if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ] && [ "$ok" -eq 1 ]; then
  echo "Message sent to client."
else
  echo "$BODY" >&2
  exit 1
fi

Response and delivery status

HTTP 2xx and JSON "sent": true mean 1MSG accepted the message for sending — not that it already reached the customer's phone. Save the id field (looks like wamid.…) to correlate delivery callbacks.

200 OKResponse
{
  "sent": true,
  "message": "Sent to [email protected]",
  "description": "Message has been sent to the provider",
  "id": "wamid.HBgLMzgwNjM5..."
}
  • sent

    Accepted for sending — not yet on the customer's phone

  • id

    Store it; delivery callbacks and hookInfo are keyed on this

Delivery statuses and webhooks →

Common errors

StatusAPI responseCauseFix
200Message was not sent: provide chatId, phone, bsuid, or usernameNo recipient the channel could resolve.Pass exactly one recipient: phone (country code plus number, digits only), chatId (for example [email protected]) or bsuid.
401token is requiredThe request has no token.Add your channel token as the token query parameter: https://api.1msg.io/{channelId}/{method}?token=…
429too many requests. please try laterThe channel is over its send rate.Queue messages on your side and retry with exponential backoff.

All error codes →

Common questions

Related

Build for WhatsApp in hours
without infrastructure hassle