Skip to main content

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​

HeaderValueRequired
AuthorizationBearer <your-api-key>Yes
Content-Typeapplication/jsonYes

Body Parameters​

ParameterTypeRequiredDescription
devicesarrayYes1–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"
}
]
}
Key your import on external_id

Rows 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.

Do not send sdk_version for imported devices

Same 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."
}
]
}
FieldTypeDescription
job_idstringPoll the status route with this
acceptednumberRows queued for processing
rejectednumberRows rejected on shape and never queued
errorsarrayThe 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"
}
StatusMeaning
queuedAccepted, not started. Keep polling.
processingRunning. Keep polling.
completedEvery accepted row was attempted. Check failed and read errors.
failedThe 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:

CodeMeaningWhat to do
CONTACT_NOT_FOUNDNo contact matches this row's identifiersImport the contact first; a device import never creates one
CONTACT_CONFLICTThe identifiers match contacts that cannot be safely mergedUsually 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:

  1. 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.
  2. Import contacts first; this endpoint never creates one. Key them on external_id, then key your device rows on the same value.
  3. Import devices here, 1,000 at a time, omitting sdk_version. Poll each job and reconcile its errors before moving on.
  4. 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.
  5. Then ship the app build carrying the Arsel SDK. Imported devices are already reachable, so campaigns work before users update.
Web push does not migrate as tokens

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 -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"

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.

Fewer than 1 or more than 1,000 items:

{
"status_code": 422,
"name": "validation_error",
"message": "devices must contain no more than 1000 elements"
}