Limits and large sends
Limits and quotas
Section titled “Limits and quotas”The console and all your keys share your organization’s quotas. To read the current values, call GetSettings with {} and read limits.
| Limit | Field in limits |
Default | What it counts |
|---|---|---|---|
| Single sends each second | servicePerSecond |
100 | Messages sent with SendServiceMessage |
| Batch rate | serviceBatchPerSecond |
200 | Batch items 1.ae sends each second |
| Each day | servicePerDay |
100,000 | All messages, single and batch, in a UTC calendar day |
| Each resident each day | servicePerSubjectPerDay |
10 | Notices to one resident in a UTC day. Plain messages do not count. |
| Items in a batch | maxServiceBatch |
500 | Items in one SendServiceMessages call |
| Batch size | maxServiceBatchBytes |
4 MiB | Bytes in one SendServiceMessages request |
- When 1.ae accepts a batch, it counts the valid items against the daily quota. 1.ae returns the unit of each item that it does not send. 1.ae refuses the whole batch if it goes past the daily quota.
- The queue holds at most 2 hours of your batch rate. At the default rate, that is 1,440,000 items. 1.ae refuses the whole batch that goes past it with
QUEUE_FULL. Batches that 1.ae already accepted continue. - An item past the daily limit for one resident fails alone, as
ERROR.
To change your quotas, ask your 1.ae contact. A 1.ae operator sets them.
Large sends
Section titled “Large sends”There is no “send to everyone” call. To reach a large population, send your list as batches of up to 500 items. 1.ae sends them at your batch rate. Your system does not control the speed.
- Agree the send with your 1.ae contact before the day. 1.ae sets a daily quota and a batch rate that are large enough.
- Read
GetSettings. UsemaxServiceBatchas the batch size. - Send the batches one after another. Give each batch a
batchKeyand each item an idempotency key from your job and row numbers. - If a batch is refused with
QUEUE_FULL, wait forretry_after_secondsand send the same batch again. - Read each batch with
GetServiceBatchuntil it isDONE, and store the results with your own records. Keep theNO_ACCOUNTandREFUSEDrecords for your other channels.
| Recipients | Batches of 500 | Batch rate | Time to send |
|---|---|---|---|
| 10,000 | 20 | 200 (default) | about 1 minute |
| 100,000 | 200 | 200 (default) | about 8 minutes |
| 1,000,000 | 2,000 | 200 (default) | about 83 minutes |
| 1,000,000 | 2,000 | 1,000 | about 17 minutes |
The daily quota must be at least the number of recipients. The default of 100,000 a day is enough for the first two rows only. The times include only the batch rate. For a send to more than 100,000 recipients, 1.ae confirms the rate.
import os, time, requests
API = "https://api.1.ae/horizon.apis.chat.v1.ChatService/"HEADERS = {"Authorization": f"Bearer {os.environ['ONEAE_API_KEY']}", "Connect-Protocol-Version": "1"}
def call(method, body): while True: response = requests.post(API + method, json=body, headers=HEADERS, timeout=60) if response.status_code in (429, 503): # resource_exhausted, unavailable time.sleep(retry_after_seconds(response.json())) continue response.raise_for_status() return response.json()
def retry_after_seconds(error): for detail in error.get("details", []): metadata = detail.get("debug", {}).get("metadata", {}) if "retry_after_seconds" in metadata: return max(1, int(metadata["retry_after_seconds"])) return 1
def send(job, rows, batch_size=500): # rows: [(row_number, item)], each item with "to", "content" and an optional "serviceUpdate" batch_ids = [] for start in range(0, len(rows), batch_size): chunk = rows[start:start + batch_size] accepted = call("SendServiceMessages", { "batchKey": f"{job}/{start // batch_size}", "items": [{**item, "idempotencyKey": f"{job}/{row}"} for row, item in chunk]}) batch_ids.append(accepted["batchId"]) for batch_id in batch_ids: index = 0 while True: page = call("GetServiceBatch", {"batchId": batch_id, "fromIndex": index}) store(batch_id, page.get("results", [])) # your own record if page.get("nextIndex"): index = page["nextIndex"] elif page.get("state") in ("SERVICE_BATCH_STATE_DONE", "SERVICE_BATCH_STATE_CANCELLED"): break else: time.sleep(10)If the process stops, run the job again with the same job ID. The batch keys and idempotency keys prevent duplicate messages.