Get the next line

Which of your lines someone new would get right now

GET/v1/lines/available

Use this when a person is about to write to you first — on a sign-up page, in an app, on a printed card — and you need to tell them which number to text. If your project has several lines, it answers with the one Mapier would give somebody new right now.

It picks the line the same way a first send to a new person does. It considers only your active lines on the channel whose connection is up and that still have room for new people. Among those, it prefers, in order:

  1. the line with the healthiest connection;
  2. a line that has not reached today's pace for new people;
  3. the line with the most room left before its limit;
  4. the oldest line.

Lines that are paused, full or whose connection is down are never picked.

It reserves nothing. Two people shown the same number can both text it, and a send in between can change the answer. Ask again each time you show a number, rather than caching one.

If the person is new to your project, texting that number pins them to that line, and the line counts them. If they are already on another of your lines, they stay pinned there, and this line counts them too. Later sends that name no line go out on the line they last wrote to, so on this one. The whole order is in Replying.

curl "https://api.mapier.ai/v1/lines/available?channel=imessage" \
  -H "Authorization: Bearer $MAPIER_API_KEY" \
  -H "x-mapier-version: 2026-12-01"

Request

Prop

Type

Response

200 OK
{
  "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d",
  "address": "+14155550142",
  "channel": "imessage"
}

Prop

Type

When no line can take somebody new

When every line on that channel is full, paused or down, this answers with the same 503 a first send to somebody new would get:

  • no_line when there is no active line at all;
  • capacity_exhausted when every line is full;
  • line_unavailable with details.reason: "transport_down" when every line's connection is down.

Show the person something other than a number until it clears. GET /v1/whoami shows each line's room in contactsAssigned, maxContacts and takesNewContacts.

Errors

StatusCodeCause
400bad_requestWith a personal access token, no x-mapier-project header
401invalid_credentialsNo key, or one that is unknown, revoked or expired
403forbiddenA personal access token not made for this environment, or whose owner's role no longer allows this
403insufficient_scopeA personal access token without the lines:read scope
404not_foundWith a personal access token, an x-mapier-project it cannot reach
409project_archivedThe project is archived
422validation_failedchannel is not a channel the API knows, or is omitted on a project with lines on more than one channel, which details[].channels lists
429rate_limited120 requests per minute, per key; the Retry-After header says how long to wait
500internal_errorMapier failed on its side; give requestId to support
503no_line · capacity_exhausted · line_unavailableNo line can take somebody new right now; see When no line can take somebody new
503service_busyMapier is busy and did nothing; wait details.retryAfter seconds and call again
503upstream_unavailableMapier could not answer right now; retry with backoff

Guide