The short answer
Add a REST API with per-tenant keys, stable resource names, pagination, idempotency and versioning, and add webhooks that are signed, retried with backoff and visible in a delivery log. Start with the two or three integrations customers ask for, document them with examples, and treat the API as a product you cannot casually change.
On this page
Customers want your product to talk to their accounting software, their spreadsheets, their other systems. An API lets them pull and push data. Webhooks let your product tell them when something happens. Together they turn a SaaS from a tool into part of a workflow, and they reduce “can you add an export?” requests.
What do customers actually need?
Before designing anything, collect the real requests. Typically they fall into three groups:
- Read data out: reports, invoices, records, to feed another system.
- Write data in: import customers, create orders or bookings from another source.
- Be told about events: “a payment succeeded”, “a booking was cancelled”, “a status changed”.
Build the smallest API that covers these for the top two or three integrations. An API with 80 endpoints that nobody uses is a liability.
How should the API be shaped?
For most SaaS products, a plain JSON REST API is the right choice. The rules that save pain later:
- Resources with stable names and ids. Use opaque identifiers, not database row numbers.
- Consistent errors. One error format with a machine-readable code, a human message and a request id.
- Pagination from day one. Cursor-based paging, not offsets, for lists that change.
- Filtering and sorting on the fields people really use, with limits.
- Idempotency keys for writes. A client that retries a “create payment” after a timeout must not create two. Store the key and the result in the database, not in memory, so it works on any server.
- Dates in ISO 8601 with a time zone, money as integer minor units with a currency code.
- Versioning. Put the version in the URL or a header, and promise that you will not change the meaning of a version. Add fields freely; never remove or rename them within a version.
- An OpenAPI description generated from the code or the code from it, so docs, tests and client libraries stay in step.
How do customers authenticate?
- API keys per tenant, created by an admin, shown once, stored hashed, with a name and a last-used date. Allow several keys so customers can rotate without downtime.
- Scopes. Read-only keys, and keys limited to one area, so a reporting tool cannot delete records.
- OAuth 2.0 if third-party apps will act for your users. It is more work, so start with keys unless you are building a marketplace.
- Tenant isolation. The key decides the tenant. Every query is scoped by it, and a test proves one tenant’s key can never read another’s data. See proving tenant isolation in CI.
What about rate limits?
Set per-key limits, return a clear status and a header that says when to retry, and count requests in the database or a shared store so the limit holds when you run more than one server. In-memory limits break when you add a second server: saas-ready-to-move-servers.
How do webhooks work?
A webhook is a request your server sends to a URL the customer registers, when an event happens. Doing it well is mostly about failure:
- Events are rows first. Write the event to your database in the same transaction as the change that caused it. A background job then delivers it. This way you never send an event for a change that rolled back, or lose one when the server restarts.
- Sign every delivery. Include a timestamp and an HMAC signature of the body using a per-endpoint secret, so the receiver can check who sent it and reject replays.
- Retry with backoff. Receivers go down. Retry for some days with growing delays, then mark the endpoint as failing and tell the owner.
- At-least-once delivery. Tell customers plainly that they may receive an event twice, and include a unique event id so they can ignore duplicates.
- Do not promise order. Include a version or timestamp so receivers can sort out of order events, or send small events and let them fetch current state.
- Delivery log. A page where a customer sees recent deliveries, the response code and a “resend” button. This removes most support tickets.
- Safe destinations. Check URLs to avoid your server being used to reach internal addresses (server-side request forgery), and set short timeouts.
- Background jobs that are safe with two copies running. Use a queue with singleton scheduling or a database lock, so that a second server does not send each event twice.
Our products use the same pattern for notifications: a queue, a lock on the rows being sent, and a status column with defined moves. See status columns as state machines; a webhook delivery (pending, delivered, failed, disabled) is exactly that.
What do you document first?
- A “get started in five minutes” page: create a key, make one call, see a result.
- One example per endpoint, in curl and in one or two languages.
- The error list, the rate limits and the webhook signature check, with code.
- A changelog, so customers can see what changed.
Documentation is part of the product. Customers judge your API by how fast they get to the first successful call.
How do you test an API?
Test the contract, not just the happy path. We use property-based API fuzzing against the OpenAPI description, and it found server errors that ordinary tests missed: API fuzzing found server errors. Also test authentication on every endpoint, and the tenant check in particular.
What should you not do?
- Do not expose your database schema as the API. It locks your internals.
- Do not let the web app use private endpoints that the API does not. The best test of an API is that your own app uses it.
- Do not add endpoints without an owner and a deprecation plan.
Working with us
We design and build APIs and multi-tenant SaaS back ends: tenant-scoped keys, documented and tested contracts, and webhooks with a delivery log. Tell us which tools your customers want to connect through the contact page, or see our SaaS platform work.