Bulk Provisioning
When to use this
Bulk provisioning is designed for:
- Migrations — moving a large subscriber base from another platform to kurnl
- New building activations — activating an entire first-line building at once (every suite wired to its own port)
- Batch imports — provisioning a list of new subscribers from a CSV or external system
Bulk provisioning takes first-line buildings only. An item whose port is in a
second- or third-line building, in an unclassified building, or on a switch with
no building comes back as an error with error_code: "install_required"; the
rest of the batch runs. Order those suites one by one with
CKO-04 provider-initiated and a unit_id.
For single subscribers, use CKO-04 provider-initiated or CKO-03 instead.
How it works
The POST is synchronous per item: kurnl creates the subscriber and
subscription and queues the SSH job for every item inline, then returns
200 with a per-item result list. Only the switch SSH step runs in the
background — expect a long-running request for big batches. You then poll the
batch status endpoint to track the SSH jobs.
sequenceDiagram participant YS as Your System participant KW as kurnl API
YS->>KW: POST /provisioning/bulk (up to 100 items) KW-->>YS: 200 { batch_id, queued, failed, items[] } loop Poll while jobs run YS->>KW: GET /provisioning/bulk/{batch_id} KW-->>YS: { batch_id, items[] with job_status } endSubmit a batch
Each item wraps the full subscriber object (same shape as
provider-initiated provisioning) plus a
plan_version_id, a location_hash or location_identifier, and optionally a billing block
(see Billing per item).
curl -X POST https://middleware.kurnl.ca/partner/provisioning/bulk \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "items": [ { "plan_version_id": "f7e8d9c0-...", "location_hash": "ab12cd34ef", "subscriber": { "email": "alice@example.com", "username": "alice", "invoice_contact_detail": { "firstname": "Alice", "lastname": "Smith", "email": "alice@example.com" }, "contract_contact_detail": { "firstname": "Alice", "lastname": "Smith", "email": "alice@example.com" }, "invoice_address": { "street": "Maple St", "housenumber": "42", "postalcode": "A1B 2C3", "city": "Vancouver", "province": "BC", "country": "Canada" } } }, { "plan_version_id": "f7e8d9c0-...", "location_hash": "cd34ef5678", "subscriber": { "email": "bob@example.com", "username": "bob", "invoice_contact_detail": { "firstname": "Bob", "lastname": "Lee", "email": "bob@example.com" }, "contract_contact_detail": { "firstname": "Bob", "lastname": "Lee", "email": "bob@example.com" }, "invoice_address": { "street": "Oak Ave", "housenumber": "7", "postalcode": "V5K 0A1", "city": "Vancouver", "province": "BC", "country": "Canada" } } } ] }'Response — 200 OK (synchronous, per-item results):
{ "batch_id": "batch-uuid-...", "total": 3, "queued": 1, "failed": 2, "items": [ { "subscriber_email": "alice@example.com", "job_id": "3d6e8f12-...", "subscription_id": "8c4a1b9e-...", "subscriber_id": "2f5d7a0c-...", "status": "queued", "error": null, "billing_owner": "partner" }, { "subscriber_email": "bob@example.com", "status": "error", "error": "Location not found" }, { "subscriber_email": "carol@example.com", "status": "error", "error": "This port is not in a first-line building — order the suite with POST /partner/provisioning/provider-initiated and its unit_id.", "error_code": "install_required" } ]}status per item is "queued" or "error". A failed item may carry a
machine-readable error_code (for example install_required); branch on it
rather than on the error text.
Poll for status
curl https://middleware.kurnl.ca/partner/provisioning/bulk/{batch_id} \ -H "X-API-Key: YOUR_API_KEY"Response:
{ "batch_id": "batch-uuid-...", "items": [ { "subscriber_email": "alice@example.com", "job_id": "3d6e8f12-...", "subscription_id": "8c4a1b9e-...", "job_status": "completed", "steps_completed": 6, "total_steps": 6, "error": null }, { "subscriber_email": "bob@example.com", "job_status": "error", "error": "Location not found" } ]}job_status is one of pending, running, completed, failed, error,
unknown. There is no batch-level status field — aggregate the item states
client-side (the batch is done when no item is pending or running).
Unknown batch_id returns 404; another provider’s batch returns 403.
Handling partial failures
Individual item failures don’t stop the rest of the batch: failed items come
back with "status": "error" and an "error" message in the POST response —
and, when there is one, an "error_code". The poll returns the same error_code
for the item. An install_required item is not fixed by resubmitting: the port
is not in a first-line building, so order that suite with CKO-04 instead.
Fix the cause (e.g. correct the location hash) and resubmit those items.
Resubmitting is safe: provisioning is idempotent per item — the same
subscriber email + plan version + location returns the existing subscription
instead of creating a duplicate. A port_in_use item is not fixed by
resubmitting: another live order holds the port.
Billing per item
Every item takes the same optional billing block as a single
provider-initiated order. Without it kurnl
provisions and you bill. With owner: "kurnl" and the customer’s id from your Stripe account, kurnl
adopts that customer and bills the subscription — a prorated first invoice at activation, then monthly on
billing_day:
{ "plan_version_id": "f7e8d9c0-...", "location_hash": "ab12cd34ef", "billing": { "owner": "kurnl", "stripe_customer_id": "cus_Qx7…", "billing_day": 1 }, "subscriber": { "...": "..." }}A batch may mix partner-billed and kurnl-billed items. The billing pre-flight runs per item, before that item
writes anything: an item that fails it comes back with "status": "error" and the reason in error, prefixed
with the code (billing_not_available, stripe_customer_not_found, stripe_customer_has_no_payment_method,
stripe_customer_in_use, stripe_unavailable), and the rest of the batch continues. Each item’s result
carries billing_owner so you can confirm what kurnl recorded.
Limits
| Limit | Value |
|---|---|
| Max items per batch | 100 |
POST /provisioning/bulk rate limit |
10 requests/min |
GET /provisioning/bulk/{batch_id} rate limit |
300 requests/min |
| Batch result retention | 30 days |
If you need to provision more than 100 subscribers, split them into multiple batches (mind the 10/min rate limit on the POST).
Migration checklist
Before running a bulk migration:
Map location hashes
Every subscriber needs a valid
location_hashcorresponding to a kurnl switch port. Work with your kurnl account manager to get a mapping from your building/unit records to kurnl location hashes.Validate plan versions
Confirm your
plan_version_idvalues are active. Expired plan versions will cause the entire subscriber entry to fail.Test with a small batch
Run a batch of 3–5 subscribers first and verify they provision correctly before running the full migration.
Run in off-peak hours
Large batches generate significant switch SSH traffic. Schedule migrations during low-traffic periods.
Handle failed entries
After the batch completes, process failed entries individually. Log the errors, fix the root cause, and resubmit.