Skip to content

By the Octri team · Updated

403 Forbidden

Share

A 403 means the server knows who’s calling and won’t let them do this. New credentials for the same account won’t help, so the response should say what’s missing, like a scope, a role or a plan.

All HTTP status codes

Class
4xx client error
Defined in
RFC 9110, section 15.5.4
Retry
No
Fix
Permissions or plan
Cacheable by default
No

When your API should return 403

Return 403 when the caller is authenticated and lacks permission, like a token without the invoices:write scope, a member who isn’t an admin, or an account on a plan that doesn’t include the endpoint. Name the missing scope or role in the body so the developer knows what to ask for.

If the credentials are missing or invalid, that’s a 401. If telling the caller that the resource exists would leak something, like a private repository’s name, return a 404 to everyone who can’t see it. GitHub does this for private repositories.

How public APIs declare 403 in their OpenAPI specs

Six of the eleven public specs we score declare a 403, as they were on 4 December 2026. GitHub declares it on 491 operations, more than declare 401, and Asana on 301.

OpenAI declares 403 on 196 operations and 401 on 64, so in both of the largest specs a permission error is documented more often than a bad key.

APIOperationsDeclare 403How errors are described
GitHub1,288491Per status code
Asana302301Per status code
OpenAI406196Per status code
Box29772Per status code, plus a default
Adyen Checkout2820Per status code
SendGrid Mail33Per status code
Stripe6120One default error response
Plaid3510One default error response
Twilio1970No error responses
Slack1740One default error response
Swagger Petstore190Per status code, plus a default

Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.

Declare 403 in your OpenAPI spec

Declare 403 on operations that need a scope or a role, and use the description to say which. A reader scanning your reference sees the requirement next to the endpoint.

yaml
paths:
  /invoices:
    post:
      operationId: createInvoice
      security:
        - oauth: [invoices:write]
      responses:
        "201":
          $ref: "#/components/responses/InvoiceCreated"
        "403":
          description: The token lacks the invoices:write scope.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

What an Octri SDK does with a 403

An Octri SDK doesn’t retry a 403. The caller gets an SdkPermissionDeniedError in TypeScript, Python, Java, Kotlin, PHP and Ruby, so code can tell a permissions problem from a bad key without comparing status numbers.

In TypeScript and Python, data holds the body decoded into your declared error model, so a missing scope that your API names in the body reaches the caller as a typed field.

typescript
import { Acme, SdkPermissionDeniedError } from "acme-sdk";

const acme = new Acme({ apiKey: process.env.ACME_API_KEY });

try {
  await acme.invoices.create({ customerId: "cus_123", amount: 4200 });
} catch (err) {
  if (err instanceof SdkPermissionDeniedError) {
    // The body names the missing scope, typed from your spec.
    console.log(err.data);
  }
  throw err;
}

More on retries and typed errors in SDK error handling.

HTTP 403 questions

Should a 403 say which permission is missing?

Yes, unless naming it leaks something. GitHub sends the scopes a token has and the scopes an endpoint accepts in X-OAuth-Scopes and X-Accepted-OAuth-Scopes headers.

Is 403 right for a blocked IP address?

Yes. The server knows the request and refuses it, and new credentials won’t help. Say in the body that the address is blocked so the developer doesn’t chase a permissions bug.

Can a 403 turn into a 200 later?

Yes, once the account gets the permission. A client can try again after a plan upgrade or a role change, though never in a loop.

Share