Skip to content

Factory bulk issuance

This is the flow for collecting CSRs on a production line and issuing them in one go, up to 1,000 devices per call.

  1. Register the shipping list. Send serials, device types and chip IDs (and RTU IDs) to POST /v1/devices, up to 1,000 at a time. If any item is invalid nothing is saved and the error names the item (e.g. devices.12.chipId). Resending the same list counts existing devices as unchanged.

  2. Collect CSRs. Each device (its secure element) generates a P-256 private key and a CSR. The private key never leaves the device.

  3. Request bulk issuance. Send pairs of deviceSerial and csrPem to POST /v1/certificates/batch. You get 202 and a batch id right away. Add an Idempotency-Key so retries are safe.

  4. Wait for completion. Poll GET /v1/batches/{id} every few seconds until status is completed. Each item is issued, pending (manual issuance) or failed (with error code and message). One failure does not stop the others.

  5. Download and install chains. For each issued item, call GET /v1/certificates/{serial}/chain with its certificateSerial and write it to the device.

  6. Mark as shipped. When the device leaves the factory, send status: "shipped" with PATCH /v1/devices/{serial}.

import json, time, uuid, requests
API = "https://api.pki-dev.solar-on.org"
s = requests.Session()
s.cert = ("client.crt", "client.key") # client certificate (mTLS)
s.headers["Authorization"] = f"Bearer {API_KEY}"
# 1. Shipping list
devices = [{"serial": d["serial"], "deviceType": "module", "chipId": d["chip"]} for d in lot]
s.post(f"{API}/v1/devices", json={"devices": devices}).raise_for_status()
# 3. Bulk issuance (Idempotency-Key makes retries safe)
items = [{"deviceSerial": d["serial"], "csrPem": d["csr"]} for d in lot]
r = s.post(f"{API}/v1/certificates/batch", json={"items": items},
headers={"Idempotency-Key": str(uuid.uuid4())})
r.raise_for_status()
batch_id = r.json()["id"]
# 4. Wait
while True:
batch = s.get(f"{API}/v1/batches/{batch_id}").json()
if batch["status"] == "completed":
break
time.sleep(3)
# 5. Chains
for item in batch["items"]:
if item["status"] == "issued":
chain = s.get(f"{API}/v1/certificates/{item['certificateSerial']}/chain").text
write_to_device(item["deviceSerial"], chain)
elif item["status"] == "failed":
print(item["deviceSerial"], item["error"]["code"], item["error"]["message"])
  • Limits. Registration and bulk issuance take up to 1,000 items and a 2 MB body. The rate limit is 600 calls per minute per key, so polling every few seconds is plenty.
  • Failed items. The usual ones are DEVICE_NOT_FOUND (not registered), CERTIFICATE_EXISTS (already has a valid certificate) and INVALID_CSR (not P-256 or a bad signature). Fix them and resend just those items.
  • Manual issuance. pending items become approved in GET /v1/requests/{requestId} after Solarize approves them.