Bulk Register Devices
Import up to 1,000 devices in one call. Use this to migrate an existing push audience onto Arsel.
Each item is the shape Register Device accepts, with the same (organization, installation_id) upsert and durable opt-out rules. The route is asynchronous: the request validates and queues, and you poll for the outcome.
Endpoint
POST /push/devices/bulk
Returns: 202 Accepted
How it behaves
Shape errors come back immediately; everything else is queued. A row that fails validation is reported in errors on the response and never queued. The rest are processed in the background, so a large import is never bounded by a request timeout.
Failures found during processing are not in this response. "No contact matches this reference", the most common migration error, is only known once the row is processed. Poll the status route for per-row errors and counts.
Every error carries an index: the position of the row in the devices array you submitted, so you can trace it back to your export.
The whole batch is safe to retry. Registration is an idempotent upsert on installation_id, so re-sending a batch after a partial failure re-registers the successes without duplicating them.
Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer <your-api-key> | Yes |
Content-Type | application/json | Yes |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
devices | array | Yes | 1–1,000 device objects, each the Register Device body. |
{
"devices": [
{
"email": "john.doe@example.com",
"installation_id": "install-abc123",
"platform": "android",
"device_token": "fzXn2…J3x9",
"device_timezone": "Asia/Riyadh",
"device_locale": "ar-SA"
},
{
"external_id": "user-4471",
"installation_id": "install-def456",
"platform": "ios",
"apns_environment": "production",
"device_token": "9a1c…40be"
},
{
"external_id": "user-5120",
"installation_id": "install-ghi789",
"platform": "web",
"endpoint": "https://fcm.googleapis.com/fcm/send/c9Xk…",
"p256dh_key": "BNcR…Qx4",
"auth_key": "tBHI…Z8w"
}
]
}
external_idRows are resolved by external_id, then email, then phone_number, so an export keyed on your own user id binds directly with no contact_id lookup. external_id also survives a customer changing their email or phone.
Where several identifiers on a row point at duplicate contacts, those contacts are consolidated. Where they point at contacts that cannot be reconciled, the row is reported as a 409 instead of being merged, because merging two real customers is not recoverable.
external_id is accepted only here. The single-device route does an exact lookup and would silently ignore it.
sdk_version for imported devicesSame rule as the single-device route, applied here 1,000 rows at a time. sdk_version marks a device as instrumented; sending it for a device with no embedded Arsel SDK tells Arsel to expect delivery and engagement reports that will never arrive.
Response
{
"job_id": "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a",
"accepted": 998,
"rejected": 2,
"errors": [
{
"index": 3,
"status_code": 400,
"message": "device_token is required for android and ios"
},
{
"index": 51,
"status_code": 400,
"message": "Provide at least one of contact_id, external_id, email, or phone_number."
}
]
}
| Field | Type | Description |
|---|---|---|
job_id | string | Poll the status route with this |
accepted | number | Rows queued for processing |
rejected | number | Rows rejected on shape and never queued |
errors | array | The rejected rows, each with the index it held in your devices array |
Checking progress
GET /push/imports/:job_id
Returns: 200 OK
{
"job_id": "01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a",
"status": "completed",
"total": 998,
"completed": 995,
"failed": 3,
"errors": [
{
"index": 7,
"status_code": 404,
"code": "CONTACT_NOT_FOUND",
"message": "No contact in this organization matches the supplied identifiers."
},
{
"index": 12,
"status_code": 409,
"code": "CONTACT_CONFLICT",
"message": "The identifiers on this row match more than one contact and cannot be reconciled automatically. Correct the row and re-import it."
}
],
"error_message": null,
"created_at": "2026-06-01T12:00:00.000Z",
"completed_at": "2026-06-01T12:04:11.000Z"
}
| Status | Meaning |
|---|---|
queued | Accepted, not started. Keep polling. |
processing | Running. Keep polling. |
completed | Every accepted row was attempted. Check failed and read errors. |
failed | The job itself died (not its rows). error_message says why. |
errors carries one entry per failed row, each with its index in the submitted devices array. It is bounded by the batch cap, so it is never truncated or paginated.
completed does not mean "all succeeded"It means the job attempted every row. A job can complete with failed: 3, so reconcile on the counts.
The common row failures:
| Code | Meaning | What to do |
|---|---|---|
CONTACT_NOT_FOUND | No contact matches this row's identifiers | Import the contact first; a device import never creates one |
CONTACT_CONFLICT | The identifiers match contacts that cannot be safely merged | Usually a stale address in the export. Fix the row and re-submit it |
Migrating an existing audience
The full order of operations, including the credential decisions that determine whether your tokens survive, is in the push guide. In short:
- Keep your existing Firebase project and APNs key. Tokens are bound to your credentials. A new Firebase project invalidates every Android token you hold, and no import recovers them.
- Import contacts first; this endpoint never creates one. Key them on
external_id, then key your device rows on the same value. - Import devices here, 1,000 at a time, omitting
sdk_version. Poll each job and reconcile its errors before moving on. - Apply opt-outs last, with Unregister Device. The revocation is durable and re-registration won't undo it, so it must come after the import.
- Then ship the app build carrying the Arsel SDK. Imported devices are already reachable, so campaigns work before users update.
Browser subscriptions are encrypted to the sender's VAPID key pair, so a subscription created under another provider's keys can't be sent to with different ones. Carry across the key pair itself by importing it when you provision Web Push. See Migrating an existing web audience.
Examples
Submit a batch, then poll the job until it finishes.
- cURL
- JavaScript
- Python
curl -X POST "https://api.arsel.sa/v1/push/devices/bulk" \
-H "Authorization: Bearer $ARSEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"devices": [
{
"external_id": "user-4471",
"installation_id": "install-def456",
"platform": "ios",
"apns_environment": "production",
"device_token": "9a1c…40be"
}
]
}'
# Poll with the job_id from the response
curl "https://api.arsel.sa/v1/push/imports/01957e3a-4b5c-7d8e-9f0a-1b2c3d4e5f6a" \
-H "Authorization: Bearer $ARSEL_API_KEY"
async function arsel(path, { method = "GET", body } = {}) {
const response = await fetch(`https://api.arsel.sa/v1${path}`, {
method,
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
"Content-Type": "application/json",
},
body: body && JSON.stringify(body),
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.name}: ${data.message}`);
return data;
}
// `devices` holds up to 1,000 rows from your export
const { job_id, errors } = await arsel("/push/devices/bulk", {
method: "POST",
body: { devices },
});
errors.forEach((e) => console.warn(`row ${e.index}: ${e.message}`));
let job;
do {
await new Promise((resolve) => setTimeout(resolve, 2000));
job = await arsel(`/push/imports/${job_id}`);
} while (job.status === "queued" || job.status === "processing");
console.log(`${job.completed} registered, ${job.failed} failed`);
job.errors.forEach((e) => console.warn(`row ${e.index}: ${e.code}`));
import os
import time
import requests
API = "https://api.arsel.sa/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['ARSEL_API_KEY']}"
session.hooks["response"] = lambda response, *args, **kwargs: response.raise_for_status()
# `devices` holds up to 1,000 rows from your export
result = session.post(f"{API}/push/devices/bulk", json={"devices": devices}).json()
for e in result["errors"]:
print(f"row {e['index']}: {e['message']}")
while True:
time.sleep(2)
job = session.get(f"{API}/push/imports/{result['job_id']}").json()
if job["status"] not in ("queued", "processing"):
break
print(f"{job['completed']} registered, {job['failed']} failed")
for e in job["errors"]:
print(f"row {e['index']}: {e['code']}")
Error Responses
Row-level failures are reported in errors (shape) or on the errors route (processing), never as a request error. The request itself fails only when the envelope is wrong.
- 422 Envelope
- 401 Unauthorized
- 429 Rate Limited
Fewer than 1 or more than 1,000 items:
{
"status_code": 422,
"name": "validation_error",
"message": "devices must contain no more than 1000 elements"
}
{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid API Key"
}
{
"status_code": 429,
"name": "rate_limit_exceeded",
"message": "Too many requests. Please retry after the period indicated in the retry-after header."
}