API Reference
API Reference
Complete REST API reference for secr. All endpoints accept and return JSON. An OpenAPI 3.1 spec is also available.
Overview
Base URL: https://api.secr.dev
All API routes are prefixed with /v1. For example, /v1/auth/me.
Authentication
Two methods are supported:
- Session cookie —
__secr_session(used by the dashboard) - Bearer token —
Authorization: Bearer secr_tok_...(used by the CLI and SDKs)
CSRF Protection
Cookie-authenticated mutations require the X-Requested-With: secr header. Token-authenticated requests do not need this header.
curl -X GET https://api.secr.dev/v1/auth/me \
-H "Authorization: Bearer secr_tok_abc123"Auth
| Method | Route | Description |
|---|---|---|
| POST | /auth/register | Create account + personal org |
| POST | /auth/login | Login, returns session cookie |
| POST | /auth/logout | Clear session |
| GET | /auth/me | Current user + orgs |
| POST | /auth/token | Create a scoped CLI token |
| POST | /auth/cli-auth | Dashboard-to-CLI token handoff |
| GET | /auth/tokens | List active CLI tokens |
| DELETE | /auth/tokens/:tokenId | Revoke a CLI token |
| POST | /auth/change-password | Change password (requires auth) |
| POST | /auth/send-verification | Send email verification link |
| POST | /auth/verify-email | Verify email with token |
| POST | /auth/forgot-password | Request password reset (rate-limited) |
| POST | /auth/reset-password | Reset password with token |
Projects
| Method | Route | Description |
|---|---|---|
| GET | /projects/:orgId | List projects in org |
| POST | /projects/:orgId | Create project (owner/admin) |
| GET | /projects/:orgId/:slug | Get project details |
| DELETE | /projects/:orgId/:slug | Delete project (owner only) |
| POST | /projects/:orgId/:slug/environments | Create custom environment |
| POST | /projects/:orgId/:slug/rotate-key | Rotate encryption key (owner/admin) |
Secrets
Secret routes use org slugs, not IDs.
| Method | Route | Description |
|---|---|---|
| GET | /secrets/:orgSlug/:project/:env | Pull all secrets (decrypted) |
| GET | /secrets/:orgSlug/:project/:env/keys | List keys only (no values) |
| PUT | /secrets/:orgSlug/:project/:env | Set a secret |
| POST | /secrets/:orgSlug/:project/:env/bulk | Bulk import secrets |
| GET | /secrets/:orgSlug/:project/:env/versions/:key | Secret version history |
| POST | /secrets/:orgSlug/:project/promote | Promote secrets between envs |
| POST | /secrets/:orgSlug/:project/:env/bulk-delete | Bulk delete secrets (owner/admin) |
| DELETE | /secrets/:orgSlug/:project/:env/:key | Soft-delete a secret |
Pagination & Search
The GET secrets and GET keys endpoints support optional pagination and key prefix search:
| Option | Type | Required | Description |
|---|---|---|---|
| limit | int | omit = all | Max results per page (1-500) |
| offset | int | 0 | Number of results to skip |
| search | string | No | Filter keys by prefix (case-sensitive) |
When limit is provided, the response includes a pagination object with { limit, offset, total }. When omitted, all results are returned.
GET /v1/secrets/my-org/my-proj/development?limit=10&offset=0
GET /v1/secrets/my-org/my-proj/development/keys?search=DB_&limit=20
// Response:
{
"secrets": [...],
"pagination": { "limit": 10, "offset": 0, "total": 42 }
}Organizations
| Method | Route | Description |
|---|---|---|
| POST | /orgs | Create organization |
| DELETE | /orgs/:orgId | Delete organization (owner only, cascades all data) |
Templates
Templates define required secret keys for a project. Validate an environment against the template to catch missing configuration.
| Method | Route | Description |
|---|---|---|
| GET | /templates/:orgSlug/:project | List template keys |
| POST | /templates/:orgSlug/:project | Add a template key (admin/owner) |
| DELETE | /templates/:orgSlug/:project/:key | Remove a template key (admin/owner) |
| GET | /templates/:orgSlug/:project/validate/:env | Validate env against template |
Webhooks
Webhooks fire on secret events: secret.created, secret.updated, secret.deleted, secret.bulk_set, secret.promoted, secret.bulk_delete.
| Method | Route | Description |
|---|---|---|
| GET | /webhooks/:orgId | List webhooks |
| POST | /webhooks/:orgId | Create webhook (admin/owner) |
| GET | /webhooks/:orgId/:id | Get webhook + delivery log |
| PATCH | /webhooks/:orgId/:id | Update webhook |
| DELETE | /webhooks/:orgId/:id | Delete webhook |
| POST | /webhooks/:orgId/:id/test | Send test delivery |
Members
| Method | Route | Description |
|---|---|---|
| GET | /members/:orgId | List members + pending invites |
| POST | /members/:orgId/invite | Invite a member |
| POST | /members/invite/:token/accept | Accept invitation |
| PATCH | /members/:orgId/:id | Change member role (owner only) |
| DELETE | /members/:orgId/:id | Remove member (owner/admin) |
Audit
| Method | Route | Description |
|---|---|---|
| GET | /audit/:orgId | Query audit log |
Supports query parameters: ?limit=&offset=&action=
Billing
Stripe-powered billing with hosted Checkout and Customer Portal.
| Method | Route | Description |
|---|---|---|
| GET | /billing/:orgId | Billing status + usage counts |
| POST | /billing/:orgId/checkout | Create Stripe Checkout session |
| POST | /billing/:orgId/portal | Create Stripe Customer Portal session |
| POST | /billing/webhook | Stripe webhook (no auth, signature verified) |
Admin
All admin routes require isAdmin = true on the authenticated user. Returns 403 for non-admin users.
| Method | Route | Description |
|---|---|---|
| GET | /admin/stats | Platform stats (users, orgs, projects) |
| GET | /admin/orgs | List all orgs with usage counts |
| GET | /admin/orgs/:orgId | Org detail + effective plan limits |
| PATCH | /admin/orgs/:orgId | Update org plan and/or limit overrides |
| GET | /admin/plans | List all plan configs |
| PUT | /admin/plans/:planName | Update a plan's default limits |
| GET | /admin/metrics/summary | Request metrics (?hours=N, default 24, max 168) |
Plan limit resolution
Effective limits are resolved in priority order:
- Per-org overrides —
limitOverrideson the org (highest priority) - DB plan config —
plan_configstable (runtime-editable defaults) - Hardcoded constants —
PLAN_LIMITSin@secr/shared(fallback)
Use -1 in the DB/API to represent unlimited (translates to Infinity internally).
Roles and Permissions
Access control is role-based. Each member has one of four roles:
| Permission | Owner | Admin | Developer | Viewer |
|---|---|---|---|---|
| Read secrets | All envs | All envs | dev + staging | dev only |
| Write secrets | Yes | Yes | Yes | No |
| Promote secrets | Yes | Yes | Yes | No |
| Manage templates | Yes | Yes | No | No |
| Manage members | Yes | Yes | No | No |
| Delete projects | Yes | No | No | No |
| View audit log | Yes | Yes | No | No |
Start building with the API
curl https://api.secr.dev/v1/auth/me \
-H "Authorization: Bearer secr_tok_..."