Omono API
Menu Rate limits

Rate limits

View as Markdown

Omono limits how many requests each API key, and your organisation as a whole, can make. This guide lists the limits, explains how a write with many line items, a large body or long descriptions counts, and shows you how to plan your integration so that it stays well inside them. The limits protect the platform, so they can change at any time, as Changes to the limits explains.

The limits#

Each API key has these limits:

Limit Allowance
Sustained 120 requests a minute
Burst 10 requests a second
In flight 4 requests at the same time
Writes 30 writes a minute
Daily 10,000 requests a day

A write is any POST, PATCH or DELETE request, including actions such as /activate. Writes also count towards the other limits, like any other request. The daily limit applies to each calendar day in UTC.

Each limit counts requests in a fixed window. A per-minute limit starts its window with the first request it counts after the previous window ended, and the window lasts 60 seconds. It isn't a clock minute, and it doesn't slide: when the window ends, the count starts again from 0. The burst limits work in the same way over 1 second, and the daily limit over the calendar day in UTC. RateLimit-Reset tells you when the current window ends, as Watch your remaining allowance explains.

All the keys of your organisation also share these limits:

Limit Allowance
Sustained 240 requests a minute
Burst 20 requests a second
In flight 8 requests at the same time

When you go over a limit, the request fails with a 429 error and the code rate-limited. The Retry-After header tells you how many seconds to wait. Wait that long, then send the request again. If you keep getting 429 errors, back off exponentially: wait longer after each one, for example twice as long, and add a small random delay so that your retries don't all arrive at the same moment.

How heavy writes count#

A write that works on many line items, or that carries a large body, costs more than an ordinary request, because it does more work. Its cost has two parts, which are added together:

  • Line items. One for every 10 line items, rounded up. Which line items count depends on the request, as the table below shows. Some requests also count BOM items. An assembly is a stock item built from other stock items, and its BOM items are those components. So a new line item on a quote or sales order for an assembly with 9 components counts as 10, because Omono copies the 9 components onto it.
  • Size. One for every full 32 KB (32,768 bytes) of the request body. The first 32 KB are free, so most writes never pay this part. Omono measures the body as JSON without any spaces between values, and after it decompresses a compressed body. Description text that Omono stores for your line items, and that the body didn't carry, counts like body bytes: Omono adds it to the size of the body. That's mainly the description that Omono copies from the stock item when you send a new line item without a description, as Line item descriptions explains.

A write always counts as at least 1, and never as more than 100.

The whole cost counts against your organisation's limit of 240 requests a minute. Against your key's limit of 30 writes a minute, a write counts as its cost but never as more than 30. Against your key's other limits, the sustained, burst, in-flight and daily limits, every request counts as 1, however heavy it is.

A write never counts as more than a limit allows in a minute, so even the heaviest write can always go through. Against your key's writes limit it counts as at most that limit. Against your organisation's limit, and Omono's overall limit, it counts as at most your organisation's limit, which matters only when that limit is lower than the write's cost, for example after Omono lowers it. A write that counts as a whole limit goes through when no other request has counted against that limit in the current minute. Until then it fails with a 429 error, so wait for Retry-After and retry it.

Which requests count more#

Only the requests in this table pay these costs. Where a cell names two numbers, the larger one counts. Every other request, read or write, counts as 1, except an upload, which counts by its size, as Uploads explains. That includes completing a task, and every action that isn't in the table.

Request The line items it counts
POST /quotes, POST /sales-orders, POST /credit-notes, POST /purchase-orders The entries in lineItems.
PATCH /quotes/{id}, PATCH /sales-orders/{id}, PATCH /credit-notes/{id}, PATCH /purchase-orders/{id} With lineItems: the entries you send, or the line items the document already has. With lineItemOrder: the line items the document already has. Without either: none.
POST /sales-orders/{id}/dispatches, POST /purchase-orders/{id}/deliveries The entries in lineItems.
PATCH /sales-orders/{id}/dispatches/{dispatchId}, PATCH /purchase-orders/{id}/deliveries/{deliveryId} The line items on the dispatch or delivery, with any you add, because Omono saves them all again, even when you only change the date. A request that changes nothing counts as 1.
DELETE /sales-orders/{id}/dispatches/{dispatchId}, DELETE /purchase-orders/{id}/deliveries/{deliveryId} The line items on the dispatch or delivery, because Omono deletes them all.
DELETE /quotes/{id}, DELETE /sales-orders/{id}, DELETE /credit-notes/{id}, DELETE /purchase-orders/{id} The document's line items and their BOM items, and the line items of its dispatches or deliveries and their BOM items, because Omono deletes them all.
POST /sales-orders/{id}/transitions A move that allocates stock, releases it or ships the dispatch: the dispatch's line items and their BOM items. Any other move, such as putting the dispatch on hold: none.
POST /sales-orders/{id}/activate The order's line items.
POST /quotes/{id}/mark-won The line items of the revision you win, and their BOM items.
POST /purchase-orders/{id}/issue, POST /purchase-orders/{id}/cancel The order's line items.
POST /credit-notes/{id}/complete The credit note's line items.
POST /stock-items, PATCH /stock-items/{id} The entries in bom.

On a quote or sales order, each new line item for an assembly in lineItems also counts the BOM items that Omono copies from the assembly. On a stock item, every entry in bom counts, even one that changes nothing, so a write with 250 bom entries counts as 25.

In these examples, every body except the last is smaller than 32 KB:

Request What's counted Counts as
Create a sales order with 8 line items 8 line items 1 write
Create a sales order with 45 line items 45 line items 5 writes
Create a sales order with 20 line items, each for an assembly with 9 components 200: 20 line items and 180 BOM items 20 writes
Add one line item to an order that has 250 250 line items 25 writes
Change a field on that 250-line order, without lineItems Nothing 1 write
Create a dispatch with 120 line items 120 line items 12 writes
Change only the date of that dispatch Its 120 line items 12 writes
Move that dispatch to an allocated status, when 30 of its line items are assemblies with 4 components each 240: 120 line items and 120 BOM items 24 writes
Then put that dispatch on hold Nothing 1 write
Delete a dispatch with 120 line items Its 120 line items 12 writes
Delete a Draft sales order with 40 line items and one dispatch of those 40 Its 80 line items 8 writes
Issue a purchase order with 60 line items 60 line items 6 writes
Create an assembly with 120 components in bom 120 BOM entries 12 writes
Create a stock item with long descriptions, in a 100 KB body 3 full blocks of 32 KB 3 writes

So any PATCH with lineItems on a 250-line document uses at least 25 of your 30 writes a minute. So does any change to a dispatch or delivery with 250 line items, deleting one, and any move that allocates, releases or ships a dispatch with 250 line items.

The most one request can carry#

The line items and BOM items in one request can add up to at most 1,000. For example, 250 new line items for assemblies with 4 components each add up to 1,250, so the request fails with a 422 error and the code validation-failed on the field lineItems. Send the line items in more than one request instead: create the document with some of them, then add the rest with a PATCH.

Line item descriptions#

Omono stores the description of each line item twice, as formatted text and as plain text. When you send a new line item without a description, Omono copies the description of its stock item onto it. So a small request can store a lot of text. Three rules apply to a POST or a PATCH with lineItems on a quote, sales order, credit note or purchase order:

  • The copied text counts in the cost of the write. Each byte of description text that Omono stores, and that your body didn't carry, counts like a byte of the body, as Size explains. For example, 100 new line items that each copy a description of 2,000 characters add about 200 KB to the size. So the write counts as about 16, not 10.
  • One request can store at most 8 MB (8,000,000 bytes) of line item descriptions. Omono counts the descriptions as it stores them, the formatted text and the plain text together, so a description counts as about twice its size or more. A request over the limit fails with a 422 error and the code validation-failed on the field lineItems, and nothing changes. Send fewer line items in each request, or send a shorter description for each line item.
  • Your organisation can store at most 256 MB of descriptions and notes a day, in UTC. All the keys of your organisation share this limit. A write that would take your organisation past it fails with a 429 error and the code rate-limited, and nothing changes. Retry-After gives the seconds until 00:00 UTC. The RateLimit-* headers don't count this limit. Requests that store no descriptions still work.

Only the descriptions that a request stores count: those of new line items, and those of line items whose description changes. A line item that keeps its description adds nothing.

Other requests store description text or notes, and the first rule and the daily limit apply to them too. The limit of 8 MB for one request doesn't.

  • POST /stock-items and PATCH /stock-items/{id}. The description and the purchasingDescription of the stock item count. In a PATCH, a description counts only when you change it.
  • POST /quotes/{id}/mark-won. Omono copies the line items of the revision to the new sales order, and it stores their descriptions again. That text counts in the cost of the request and against the daily limit. A request that returns applied: false copies nothing, so it counts nothing.
  • POST /<record>/{id}/notes. A note on a company, quote, sales order, credit note, purchase order or stock item is stored as formatted text and as plain text, as a description is, and a task's note as plain text. It counts against the daily limit. One record can also take about 50 notes through the API in any 24 hours, from all your keys together. Omono checks the count before it adds the note, so notes sent at the same moment can pass it by a few. Past it, the next note fails with a 429 error and the code rate-limited. This 429 is a cap on the record for the day, not a limit on your requests: its Retry-After can be many hours, the time until the oldest of those notes is 24 hours old, and your other requests still work.

When the cost is counted#

Omono counts the whole cost at one point in each request, after some of its checks and before the others:

  • On a quote, sales order, credit note or purchase order, as soon as it has checked the format of your request, your If-Match header and the number of line items, and before it checks your data. The part of the cost for description text that the body didn't carry is the exception: Omono counts it after it has checked your line items, just before it writes anything.
  • On a new dispatch or delivery, once it has checked that the order can take one, and before it checks your line items.
  • On a change to a dispatch or delivery, once it has checked the dispatch's or delivery's stage and your If-Match header, and before it checks your line items.
  • On a DELETE, after all of its checks, just before it deletes anything. A DELETE that its checks refuse counts as 1. A delete of a Draft that passes its checks and is then refused, because someone changed the record at the same moment, counts in full.
  • On an action, such as /transitions, /activate or /issue, after all of its checks, just before it changes anything. An action that its checks refuse, or that finds the record already as you asked and answers "applied": false, counts as 1. Two exceptions count in full: repeating a move to a shipped status, when it finishes a ship whose invoicing failed, and an action that passes its checks and then loses a race to another change.
  • On a stock item, after it has checked your fields and the IDs they refer to, and before it checks the components in bom and the part number.

This has two effects:

  • If the cost takes you over a limit, you get the 429 or 503 error first, even if the write would also have failed one of the later checks.
  • A write that fails after that point still counts in full, for example with a 422 error for an invalid reference, or a 409 error because the order is locked.

These requests count as 1, however many line items they carry:

  • A replayed request, which is a retry of a request that already succeeded. Omono answers it without running it again. A replayed upload is the exception: it still counts by its size, as Uploads explains.
  • A 409 error that says an Idempotency-Key is still in progress or was reused.
  • A write that's refused before its cost is counted, such as a 400, 404, 412, 413, 415 or 428 error, or a 422 error because the request doesn't match the API reference or carries too many line items.

Learn more about replays in idempotent requests.

Uploads#

An upload (POST /documents) counts as 1, plus 1 for every full MB (1,048,576 bytes) of the request, as its Content-Length header gives it. So an upload of a 300 KB file counts as 1, a 5 MB file as 6, and a file at the 20 MB limit as 21. Like the heavy writes above, it counts as at most 30 against your key's 30 writes a minute, and in full against your organisation's 240 requests a minute.

Omono counts the upload before it reads the file:

  • If the upload fails before any of the file arrives, for example because the parent ID is wrong, it counts as 1.
  • A request without a Content-Length header counts as the largest file allowed, 21, until the file has arrived. Then it counts as the size of the file.
  • A retry that Omono answers from the first request, with the same Idempotency-Key, counts its size too, because Omono reads the whole file again to check that it's the same file.

Your organisation can also upload up to 1 GB (1,024 MB) of files a day, in UTC. While a file is on its way, the upload counts as its whole request (its Content-Length, or 20 MB without one). Once the file is stored, it counts as the size of the file, and a file that isn't stored doesn't count. An upload that would take your organisation past its allowance fails with a 429 error and the code upload-limit-reached, and Retry-After gives the seconds until 00:00 UTC. Your other requests still work. If your organisation needs to upload more each day, an admin can ask Omono, as described in Get help.

PDFs#

A request for a PDF, such as Download an invoice PDF, counts as 5 against your organisation's 240 requests a minute, because Omono creates the file for you. It counts as 1 against your key's limits, like any other read. So your organisation can download up to 48 PDFs a minute. A request that fails its checks, for example because the order has no line items, counts as 1.

Omono creates each PDF when you ask for it, which usually takes 1 to 3 seconds. To download many PDFs, such as every invoice in an export, send them one or two at a time rather than all at once, so that your requests stay inside the in-flight limits.

Dashboard figures#

A request for Retrieve the dashboard figures counts as 5 against your organisation's 240 requests a minute, because Omono reads all of the period's orders, dispatches and credit notes to work out the figures. It counts as 1 against your key's limits, like any other read. Omono keeps the figures for about 30 seconds after it works them out, and a request that gets those kept figures still counts as 5, so ask for them once a minute or less often.

A search of your contacts by email address, which is List contacts with a search text that contains @, counts as 3 against your organisation's 240 requests a minute, because it looks through every email address that Omono holds for your organisation. It counts as 1 against your key's limits, like any other read. A search by name, on contacts or on companies, counts as 1.

Watch your remaining allowance#

Most responses carry three headers about the limit with the fewest requests left. They work as they always have:

RateLimit-Limit: 10
RateLimit-Remaining: 9
RateLimit-Reset: 1
Header What it tells you
RateLimit-Limit The size of that limit.
RateLimit-Remaining How many requests you have left in it. A heavy write can use more than one.
RateLimit-Reset How many seconds until it resets.

"Fewest requests left" means the smallest number of requests. So on most responses the three headers describe your burst limit of 10 a second. RateLimit-Remaining is never more than you have left in any of the limits that RateLimit-Policy lists.

The same responses also carry RateLimit-Policy, which lists every limit that applies to the request. Each item is the limit's name in quotes, then q, the number of requests it allows, and w, its window in seconds:

RateLimit-Policy: "burst";q=10;w=1, "sustained";q=120;w=60, "daily";q=10000;w=86400, "org-burst";q=20;w=1, "org";q=240;w=60
Name The limit
burst Your key's requests a second.
sustained Your key's requests a minute.
writes Your key's writes a minute. It's listed on a write only.
daily Your key's requests a day. The day is the UTC day.
org-burst Your organisation's requests a second, all keys together.
org Your organisation's requests a minute, all keys together.

The sizes are the ones that apply to you now, including a higher limit that Omono has set for your key or your organisation. Two limits can have the same size; the name tells them apart. The in-flight limits aren't listed, because they count requests at the same time, not requests in a window.

And they carry RateLimit, which gives the requests left in every one of those limits. Each item is the limit's name in quotes, then a, the number of requests you have left in it, and w, the number of seconds until it resets:

RateLimit: "burst";a=9;w=1, "sustained";a=30;w=22, "daily";a=9880;w=40112, "org-burst";a=19;w=1, "org";a=228;w=22

The limits are the same as in RateLimit-Policy, with the same names and in the same order. The numbers count this request, including the extra requests that a heavy request uses up. Read RateLimit-Policy to learn your limits, and RateLimit to learn how much of each you have left. Both headers use the syntax of the current draft of the IETF rate-limit headers work, which isn't final, as Compatibility explains.

On a 429 error, the three headers describe the limit that refused the request, also when it refused a heavy write, and RateLimit-Reset and Retry-After both tell you how many seconds to wait. In RateLimit, that limit's item has a=0, and its w is the same as Retry-After. The limits after it in RateLimit-Policy weren't checked, so they aren't in RateLimit. The in-flight limits only appear in the three headers when they refuse a request, and they're never in RateLimit. Whatever the headers say, wait for the number of seconds in Retry-After before you send the request again.

Pace a bulk read#

To read many pages one after another, such as a first copy of a large list, pace your requests instead of sending them as fast as you can. Read the "sustained" item of RateLimit on each response: a is the requests you have left this minute, and w the seconds until the minute starts again. Spread the requests you have left over the seconds that are left: wait about w divided by a seconds before the next request. At 120 requests a minute from the start of a minute, that's about one request each half second. Then the burst limit never refuses you, and your requests spread over the whole minute. At full speed, they would be used up in about 12 seconds, and every request for the rest of the minute would fail. If a is 0, wait w seconds. If you still get a 429 error, wait for the number of seconds in Retry-After, then carry on from the same page. Keep other jobs of the same key in mind: they use the same limits. Your organisation's "org" item counts the requests of all its keys, so pace by it too when other keys are busy.

When a request takes too long#

If a request hasn't finished after 15 seconds, the API stops waiting and answers with a 503 error, the code request-timeout and Retry-After: 5. What to do next depends on the request:

  • A read didn't change anything, so you can send it again.
  • A write may still complete. Retry it with the same Idempotency-Key. While the first request is still running, the retry gets a 409 error with the code idempotency-in-progress. Once the first request finishes, the retry gets its result. You can also read the record before you retry.
  • An upload has the same 15 seconds, but they only start once the whole file has arrived and Omono has stored it. Omono waits up to 30 seconds for the file to be stored. After that, the upload fails in the same way, and no document is created.

Omono also stops any single read of your data that takes longer than 10 seconds, even if the request as a whole hasn't reached 15 seconds. The request then fails in the same way, with a 503 error, the code request-timeout and Retry-After: 5, and you handle it in the same way.

Plan your requests#

For most integrations, the daily limit is the one to plan for. For example, polling nine lists every 2 minutes, with one page each time, costs 720 requests a list each day, or 6,480 requests in total. That leaves room in the 10,000 a day for writes. To stay well inside your limits:

  • Poll each list at most every 2 minutes, and ask for full pages with limit=200.
  • Read related records with include, never with one request for each record.
  • Keep no more than four requests running at the same time.

Spread your polls over time#

Start each scheduled job at a random second, not at the start of an hour or a minute. Pick the offset once, for example 17 seconds past the minute, and keep it. Many integrations run their jobs on the hour or at the start of a minute, and Omono limits how many requests it accepts each minute and works on at the same time, from every organisation together. When too many requests arrive at the same moment, some of them fail with a 503 error and the code temporarily-unavailable, even if each integration is well inside its own limits.

This applies to every schedule:

  • Poll for changes at your random second, and poll your lists one after another, not all at once.
  • Refresh the reference lists at a random minute of the hour, not on the hour.
  • Run a daily or weekly job, such as the check of your copy, at a random time outside your busiest hours.

Loading a lot of records into Omono takes time, because of the writes limit. At 30 writes a minute, a one-time load of 5,000 records takes about 167 minutes, which is nearly three hours. That assumes each write counts as 1. Documents with many line items count more, as How heavy writes count explains: a 250-line order and its dispatch take about a minute each. For a large first load like this, an admin of your organisation can ask Omono for a temporary increase.

During a large first load, don't look a record up before each create. Read each list once at the start, keep the IDs in your own system, and create only what's missing. If a record already exists, the create fails with a 409 error, and conflictingId gives the ID of the record that holds the name or number.

Ask for a higher limit#

Omono can raise a key's limits for up to 7 days when an admin of your organisation asks, as described in Get help. A raise can go up to 120 writes a minute and 50,000 requests a day. It raises the limits of that key only, never your organisation's shared limits, so all your keys together still have to stay inside those.

Changes to the limits#

The limits on this page are today's. Omono can change them as the platform grows, and that isn't a breaking change. It can raise or lower an allowance, change how much a request counts, for example so that a read that includes many related records costs more than 1, change the most that one request can send or return, or add a new limit.

A change to a limit can take effect at once, while the API is in beta and after it becomes generally available, and the changelog lists it. That includes a change that tightens what your integration can do: a lower allowance, a higher cost for a kind of request, a new limit, or a lower maximum, such as fewer line items in one request, fewer related records in a page, a smaller page size, a smaller request body, or fewer refused requests a minute.

So read your remaining allowance from the headers on each response, rather than building today's numbers into your code.

Refused requests and bad keys#

Two more limits catch integrations that keep sending requests that can't succeed.

Refused requests. A request that Omono refuses before it runs counts towards a separate limit of 120 a minute for each key. These requests count:

  • A request without the scope it needs, or sent while API access isn't switched on, which fails with a 403 error.
  • A request to a path or method that doesn't exist, which fails with a 404 or 405 error. The API doesn't answer OPTIONS requests, so they count too.
  • A request that one of your rate limits refuses with a 429 error, or that one of Omono's overall limits refuses with a 503 error.

Once a key goes over this limit, every request it sends gets a 429 error until the minute ends. Fix the request rather than retrying it, and always wait for Retry-After before you retry a 429 error. For example, a client that keeps more requests running than its in-flight limit allows, and retries each 429 error after 1 second, can soon pass 120 refusals and be refused for the rest of the minute.

Bad keys. If one IP address sends more than 20 requests in a minute with a key that's missing, wrong, expired or revoked, Omono blocks that address for up to a minute, and its requests get 429 errors. Keys that worked in the last 24 hours keep working from that address, so one misconfigured integration doesn't block your others.

Good to know#

  • Omono as a whole also limits how many requests it accepts each minute, and how many it works on at the same time. When either is reached, you get a 503 error with the code temporarily-unavailable and a Retry-After header. It isn't caused by anything you did, so wait and retry.
  • Your organisation can never use more than half of Omono's overall limit in a minute. At the default limits this changes nothing, because your organisation's 240 requests a minute are already less than half. But if Omono lowers its overall limit to protect the platform, your organisation's limit can fall with it, and you get a 429 error when you reach it. Like any change to a limit, the changelog lists it. Your heaviest writes still go through, because a write never counts as more than your organisation's limit.
  • A 429 error from an in-flight limit carries RateLimit-Remaining: 0 and Retry-After: 1.
  • A request that's refused by one of your key's own limits doesn't use up any of your organisation's shared allowance.
  • There are no RateLimit-* headers on a 401 or 403 error, or on a 429 or 503 error that's sent before your key is checked.
  • A list page ends early once it comes to about 8 MB of JSON. So a list of records with long descriptions can take more pages, and more requests, than its limit suggests, as Page through a list explains. Omono also measures the records while it reads them, so a page with large records, or with large related records that you include, can end a little earlier than that.
  • Omono limits how much data it reads at the same time, for all requests together. When it's reading a lot, a GET can fail with a 503 error, the code temporarily-unavailable and Retry-After: 1. A write on a document can fail in the same way before it changes anything. A request that reads less than about 1 MB of records never fails for this reason. It isn't caused by your rate limits, so wait and retry.