Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge pull request #8271 from Infisical/daniel/agent-friendly-api

varonix5be03882a1cc
diff --cc backend/src/server/plugins/error-handler.ts
index 56eb5c2570,242fcb7a61..cb28431800
--- a/backend/src/server/plugins/error-handler.ts
+++ b/backend/src/server/plugins/error-handler.ts
@@@ -51,11 -51,22 +52,24 @@@ enum HttpStatusCodes
// eslint-disable-next-line @typescript-eslint/no-shadow
InternalServerError = 500,
GatewayTimeout = 504,
- TooManyRequests = 429
+ TooManyRequests = 429,
+ // Non-standard (nginx convention). The client is gone, so this only reaches logs and metrics.
+ ClientClosedRequest = 499
}
+ const BODY_PARSER_ERRORS = [
+ errorCodes.FST_ERR_CTP_EMPTY_JSON_BODY,
+ errorCodes.FST_ERR_CTP_INVALID_JSON_BODY,
+ errorCodes.FST_ERR_CTP_INVALID_MEDIA_TYPE,
+ errorCodes.FST_ERR_CTP_BODY_TOO_LARGE,
+ errorCodes.FST_ERR_CTP_INVALID_CONTENT_LENGTH
+ ];
+
+ const isBodyParserError = (error: Error): error is FastifyError =>
+ BODY_PARSER_ERRORS.some((BodyParserError) => error instanceof BodyParserError);
+
+ const API_REFERENCE_DOCS_URL = "https://infisical.com/docs/api-reference";
+
export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider) => {
const appCfg = getConfig();
diff --cc docs/api-reference/overview/introduction.mdx
index c080a2be4e,f3570b5d61..4dade19ca4
--- a/docs/api-reference/overview/introduction.mdx
+++ b/docs/api-reference/overview/introduction.mdx
@@@ -5,47 -5,56 +5,56 @@@ sidebarTitle: "API
icon: "book-open"
---
-Infisical's Public (REST) API provides users an alternative way to programmatically access and manage
-secrets via HTTPS requests. This can be useful for automating tasks, such as
-rotating credentials, or for integrating secret management into a larger system.
+The Infisical API is a REST API served over HTTPS. It supports every action available in the Infisical dashboard: reading and writing secrets, managing projects and machine identities, reading audit logs, and configuring the other resources in an organization.
-With the Public API, you can create, read, update, and delete secrets, as well as manage access control, query audit logs, and more.
+<Card title="Quickstart" icon="rocket" href="/api-reference/overview/quickstart">
+ Make your first authenticated request to the Infisical API using Universal Auth.
+</Card>
+
+<Tip>
+ You can also interact with Infisical programmatically using the [CLI](/cli/overview) and [SDKs](/sdks/overview).
+</Tip>
+
+## Base URL
+
+If you use Infisical Cloud, all endpoints are available under `https://app.infisical.com/api` (US region) or `https://eu.infisical.com/api` (EU region).
+
+If you self-host Infisical or run a dedicated instance, replace the host with the address of your instance: `https://<your-instance>/api`.
+
+Each endpoint page in this reference lists a path (for example, `/api/v3/secrets/raw`). The full URL for a request is the base URL followed by that path.
+ <Visibility for="agents">
+ <Info>
+ **Are you an AI agent reading this page?** Welcome. Skip the scrolling: the complete OpenAPI specification is at `/api/docs/json` on any Infisical instance, for example [app.infisical.com/api/docs/json](https://app.infisical.com/api/docs/json).
+
+ The full specification is large, so spare your context window and add the `tag` query parameter to get only the endpoints you need. For example `/api/docs/json?tag=secrets`.
+ </Info>
+ </Visibility>
+
+
## API versioning
-The API is versioned on a per-resource basis. A resource's version is only incremented for breaking changes, so different endpoints may have different version numbers (e.g., `/api/v4/secrets` vs. `/api/v1/secret-syncs`).
-
-As a best practice, always use the latest available version for each endpoint to ensure access to the most recent features and improvements.
-
-## Rate limits
-
-Infisical enforces several different types of rate limits:
-
-- **Read**: For GET and LIST operations.
-- **Write**: For CREATE, UPDATE, and DELETE operations.
-- **Secret**: Specifically for secret management operations such as getting and creating secrets.
-- **Identity Creation**: For creating new identities within an organization.
-- **Project Creation**: For creating new projects within an organization.
-
-**Self-hosted** instances have no limits, these limits apply only to **Infisical Cloud**.
-
-<Tabs>
- <Tab title="Free Plan">
- - **Read**: 200/minute
- - **Write**: 90/minute
- - **Secret**: 120/minute
- - **Identity Creation**: 30/minute
- - **Project Creation**: 30/minute
- </Tab>
- <Tab title="Pro Plan">
- - **Read**: 350/minute
- - **Write**: 200/minute
- - **Secret**: 300/minute
- - **Identity Creation**: 30/minute
- - **Project Creation**: 30/minute
- </Tab>
-</Tabs>
-
-<Note>
- Custom rate limits are available for Enterprise customers. If you need higher rate limits, please contact [email protected].
-</Note>
+Each endpoint path is versioned independently. When an endpoint changes in a way that breaks existing callers, Infisical adds a new version of that endpoint and leaves the previous version in place. Different endpoints can therefore be on different versions (for example, `/api/v4/secrets` and `/api/v1/secret-syncs`).
+
+For each endpoint, use the highest version listed in this reference.
+
+## OpenAPI
+
+Every running Infisical instance serves its OpenAPI specification at `/api/docs/json` (on Infisical Cloud, `https://app.infisical.com/api/docs/json`). Code generators and client libraries can read the specification from that URL to produce typed clients for any endpoint in this reference.
+
+## Get started
+
+<CardGroup cols={2}>
+ <Card title="Authentication" icon="key" href="/api-reference/overview/authentication">
+ Authenticate as a machine identity and use the returned access token on every request.
+ </Card>
+ <Card title="Pagination" icon="list" href="/api-reference/overview/pagination">
+ Use `offset` and `limit` to read all pages from a paginated endpoint.
+ </Card>
+ <Card title="Rate limiting" icon="gauge-high" href="/api-reference/overview/rate-limits">
+ Per-minute rate limits by category, and the format of the HTTP 429 response.
+ </Card>
+ <Card title="Errors" icon="triangle-exclamation" href="/api-reference/overview/errors">
+ The format of an error response, the common HTTP status codes, and the `reqId` field.
+ </Card>
+</CardGroup>