Send Message

There are two ways to identify receiver of the message - phone number and contact ID. If you have someone's phone number, then it's the easiest way to contact them (for testing you can of course use your own phone number). But if someone contacts you first, WhatsApp won't tell their phone number, so you have to use contact ID instead. You will get a contact ID when you receive the first message.

🚧

24-hour window policy

WhatsApp's policy says it's not possible to send a message to contact unless they've sent a message to your WhatsApp Business Account less than 24 hours prior. This means even when just testing, you have to activate the 24-hour window (by sending a message from your phone number to your WhatsApp Business Account) to be able to send messages through Amio API.

Send a Message

  1. In administration, open your WhatsApp channel.
  2. Make sure the channel mode is set to either Production or Sandbox.
  3. Copy the channel ID in detail page for later use.
  4. Go to Contacts tab and copy an ID of a contact (if you don't see any, use your personal Whatsapp and send a message to your WhatsApp account).
  5. As the last attribute, you will need organization_access_token. Go to Settings - API and copy your secret access token.
  6. Send a text message to the user using Send Text Message API.
curl -X POST \
  https://api.amio.io/v1/messages \
  -H 'authorization: Bearer {{organization_access_token}}' \
  -H 'content-type: application/json' \
  -d '{
        "channel": {
          "id": "{{channel_id}}"
        },
        "contact": {
          "id": "{{contact_id}}"
        },
        "content": {
          "type": "text",
          "payload": "Hello world!"
        }
      }'
curl -X POST \
  https://api.amio.io/v1/messages \
  -H 'authorization: Bearer {{organization_access_token}}' \
  -H 'content-type: application/json' \
  -d '{
        "channel": {
          "id": "{{channel_id}}"
        },
        "contact": {
          "phone_number": "{{contact_phone_number}}"
        },
        "content": {
          "type": "text",
          "payload": "Hello world!"
        }
      }'
  1. Open your WhatsApp app and observe that the message was received.

📘

Postman

Use Postman to test all different message types. Don't forget to set environment properties: access_token, whatsapp.channel.id and whatsapp.contact.id.


What’s Next