# Quickstart (https://docs.mapier.ai/convo/guides/get-started/quickstart)

> Send your first message with the Mapier messaging API. Text your line, such as an iMessage number, then reply from the API

> Mapier API rules for agents:
> 1. Send an `Idempotency-Key` and an `x-mapier-version` header on every command. The key is optional, but without one a retry is a second send.
> 2. A `202` means queued, not delivered. Read the result on `GET /v1/response_stream`.
> 3. Check a feature before you promise it. `GET /v1/capabilities` covers every channel, `lines[].capabilities` on `GET /v1/whoami` covers one line, and `POST /v1/commands/{type}/check` covers one call. If a request is refused, read `error.details` and follow its `remedy` when it has one.
> 4. Reply with `target.conversationId`. On a new send, name `target.channel`.
> 5. Never fall back to another channel, and never resend a command whose result is `ambiguous`.
> Full list: https://docs.mapier.ai/skill.md

Access to Mapier is by approval. New to Mapier? [Book a call](https://cal.com/mapier-homin/30min) and Mapier sets up your account during the call. If someone invited you, the invitation is the approval.

**Before you start**, you need a line in the console, such as an iMessage number, a WhatsApp number. No line yet? [Connect a line](https://docs.mapier.ai/convo/guides/connect/imessage).

<Steps>

<Step>

### Create an API key [#create-an-api-key]

Create one on the **Keys** page. It is shown once.

```bash
export MAPIER_API_KEY="mp_live_…"
```

</Step>

<Step>

### Text your line [#text-your-line]

Open a second terminal and leave this running. Incoming messages arrive here, and so does every command's result, whatever `events=` asks for.

```bash
export MAPIER_API_KEY="mp_live_…"
curl -N "https://api.mapier.ai/v1/response_stream?events=message.received" \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "x-mapier-version: 2026-12-01" \
  -H "Accept: text/event-stream"
```

```text title="Stream output"
retry: 3000
: connected
```

A `: ping` line follows every 25 seconds. It means the connection is alive.

Then send your line a message:

| Channel                                     | How to message your line                                                                                   |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| iMessage    | Text it from your phone                                                                                    |
| WhatsApp    | Message it on WhatsApp                                                                                     |
The message arrives on the stream:

```text title="Stream output"
id: 0192…
event: message.received
data: {"id":"0192…","type":"message.received","occurredAt":"…","data":{"conversationId":"a000…0001","lineId":"…","from":"+14155550142","text":"Is this real?","attachments":[],…}}
```

Copy the `conversationId`.

</Step>

<Step>

### Reply [#reply]

The reply names only the conversation. Mapier sends it from the same line, on the same channel.

```bash
curl -X POST https://api.mapier.ai/v1/commands/message.send \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: first-reply" \
  -H "x-mapier-version: 2026-12-01" \
  -d '{
    "target": { "conversationId": "a000…0001" },
    "payload": { "kind": "text", "text": "Hi! This came from the Mapier API." }
  }'
```

```json title="202 Accepted"
{
  "commandId": "…",
  "status": "queued",
  "repeated": false,
  "lineId": "…",
  "lineSelection": "reused_active_chat",
  "channel": "imessage"
}
```

`202` means Mapier accepted the request. The result follows on the stream:

```text title="Stream output"
id: 0192…
event: command
data: {"commandId":"…","type":"message.send","status":"succeeded","messageId":"…","conversationId":"a000…0001","lineId":"…"}
```

`succeeded` means the channel now has the message. It lands on your phone.

A retry with the same `Idempotency-Key` never sends twice. Leave the header off and every request is new, so two requests with no header are two messages. [Retries](https://docs.mapier.ai/convo/guides/production/retries) explains.

</Step>

</Steps>

<Callout title="Sent is not delivered">
  Delivered and read arrive later, as their own events. The stream sends them once you add
  `receipts` to `events`: `?events=message.received,receipts`. [Results and
  delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) explains each status.
</Callout>

Which receipts follow depends on the channel:

| Channel                                     | Receipts after `succeeded` |
| ------------------------------------------- | -------------------------- |
| iMessage    | Delivered and read         |
| WhatsApp    | Delivered and read         |
## Next [#next]

Connect another line on [iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) or [WhatsApp](https://docs.mapier.ai/convo/guides/connect/whatsapp). Your code does not change.
