You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When implementing a new API route, ask the user whether it should be part of the public API. If yes:
75
+
76
+
1. Add the request/response Zod schemas to `packages/web/src/openapi/publicApiSchemas.ts`, calling `.openapi('SchemaName')` on each schema to register it with a name.
77
+
2. Register the route in `packages/web/src/openapi/publicApiDocument.ts` using `registry.registerPath(...)`, assigning it to the appropriate tag.
78
+
3. Add the endpoint to the relevant group in the `API Reference` tab of `docs/docs.json`.
79
+
4. Regenerate the OpenAPI spec by running `yarn workspace @sourcebot/web openapi:generate`.
80
+
74
81
Route handlers should validate inputs using Zod schemas.
Copy file name to clipboardExpand all lines: docs/api-reference/sourcebot-public.openapi.json
+20-12Lines changed: 20 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -23,12 +23,8 @@
23
23
"description": "System health and version endpoints."
24
24
},
25
25
{
26
-
"name": "User Management (EE)",
27
-
"description": "User management endpoints. Requires the `org-management` entitlement and OWNER role."
28
-
},
29
-
{
30
-
"name": "Audit (EE)",
31
-
"description": "Audit log endpoints. Requires the `audit` entitlement and OWNER role."
26
+
"name": "Enterprise (EE)",
27
+
"description": "Enterprise endpoints for user management and audit logging."
32
28
}
33
29
],
34
30
"security": [
@@ -1100,13 +1096,13 @@
1100
1096
"bearerToken": {
1101
1097
"type": "http",
1102
1098
"scheme": "bearer",
1103
-
"description": "Send either a Sourcebot API key (`sbk_...`) or, on EE instances with OAuth enabled, an OAuth access token (`sboa_...`) in the Authorization header."
1099
+
"description": "Bearer authentication header of the form `Bearer <token>`, where `<token>` is your API key."
1104
1100
},
1105
1101
"apiKeyHeader": {
1106
1102
"type": "apiKey",
1107
1103
"in": "header",
1108
1104
"name": "X-Sourcebot-Api-Key",
1109
-
"description": "Send a Sourcebot API key (`sbk_...`) in the X-Sourcebot-Api-Key header."
1105
+
"description": "Header of the form `X-Sourcebot-Api-Key: <token>`, where `<token>` is your API key."
1110
1106
}
1111
1107
}
1112
1108
},
@@ -1828,10 +1824,13 @@
1828
1824
"get": {
1829
1825
"operationId": "getUser",
1830
1826
"tags": [
1831
-
"User Management (EE)"
1827
+
"Enterprise (EE)"
1832
1828
],
1833
1829
"summary": "Get a user",
1834
1830
"description": "Fetches profile details for a single organization member by `userId`. Only organization owners can access this endpoint.",
1831
+
"x-mint": {
1832
+
"content": "<Note>\nThis API is only available with an active Enterprise license. Please add your [license key](/docs/license-key) to activate it.\n</Note>"
1833
+
},
1835
1834
"parameters": [
1836
1835
{
1837
1836
"schema": {
@@ -1900,10 +1899,13 @@
1900
1899
"delete": {
1901
1900
"operationId": "deleteUser",
1902
1901
"tags": [
1903
-
"User Management (EE)"
1902
+
"Enterprise (EE)"
1904
1903
],
1905
1904
"summary": "Delete a user",
1906
1905
"description": "Permanently deletes a user and all associated records. Only organization owners can delete other users.",
1906
+
"x-mint": {
1907
+
"content": "<Note>\nThis API is only available with an active Enterprise license. Please add your [license key](/docs/license-key) to activate it.\n</Note>"
1908
+
},
1907
1909
"parameters": [
1908
1910
{
1909
1911
"schema": {
@@ -1974,10 +1976,13 @@
1974
1976
"get": {
1975
1977
"operationId": "listUsers",
1976
1978
"tags": [
1977
-
"User Management (EE)"
1979
+
"Enterprise (EE)"
1978
1980
],
1979
1981
"summary": "List users",
1980
1982
"description": "Returns all members of the organization. Only organization owners can access this endpoint.",
1983
+
"x-mint": {
1984
+
"content": "<Note>\nThis API is only available with an active Enterprise license. Please add your [license key](/docs/license-key) to activate it.\n</Note>"
1985
+
},
1981
1986
"responses": {
1982
1987
"200": {
1983
1988
"description": "List of organization members.",
@@ -2016,10 +2021,13 @@
2016
2021
"get": {
2017
2022
"operationId": "listAuditRecords",
2018
2023
"tags": [
2019
-
"Audit (EE)"
2024
+
"Enterprise (EE)"
2020
2025
],
2021
2026
"summary": "List audit records",
2022
2027
"description": "Returns a paginated list of audit log entries. Only organization owners can access this endpoint.",
2028
+
"x-mint": {
2029
+
"content": "<Note>\nThis API is only available with an active Enterprise license. Please add your [license key](/docs/license-key) to activate it.\n</Note>"
To securely access and interact with Sourcebot’s API, authentication is required. Users must generate an API Key, which will be used to authenticate requests.
6
+
7
+
<Note>
8
+
If [anonymous access](/docs/configuration/auth/access-settings#anonymous-access) is enabled, some endpoints will be accessible without a API key.
9
+
</Note>
10
+
11
+
## Creating an API key
12
+
13
+
Navigate to **Settings → API Keys** and click **Create API Key**. Copy the value - it is only shown once.
14
+
15
+
<Frame>
16
+
<imgsrc="/images/mcp_api_key_settings.png"alt="API Keys page in Sourcebot Settings" />
17
+
</Frame>
18
+
19
+
## Using an API key
20
+
21
+
Pass your API key as a Bearer token in the `Authorization` header on every request.
22
+
23
+
```bash
24
+
Authorization: Bearer <your-api-key>
25
+
```
26
+
27
+
For example, to call the `/api/search` endpoint:
28
+
29
+
```bash
30
+
curl -X POST https://your-sourcebot-instance.com/api/search \
description: 'Send either a Sourcebot API key (`sbk_...`) or, on EE instances with OAuth enabled, an OAuth access token (`sboa_...`) in the Authorization header.',
75
+
description: 'Bearer authentication header of the form `Bearer <token>`, where `<token>` is your API key.',
71
76
},
72
77
[securitySchemeNames.apiKeyHeader]: {
73
78
type: 'apiKey',
74
79
in: 'header',
75
80
name: 'X-Sourcebot-Api-Key',
76
-
description: 'Send a Sourcebot API key (`sbk_...`) in the X-Sourcebot-Api-Key header.',
81
+
description: 'Header of the form `X-Sourcebot-Api-Key: <token>`, where `<token>` is your API key.',
77
82
},
78
83
};
79
84
@@ -339,7 +344,7 @@ export function createPublicOpenApiDocument(version: string) {
339
344
method: 'get',
340
345
path: '/api/ee/user',
341
346
operationId: 'getUser',
342
-
tags: [eeUserManagementTag.name],
347
+
tags: [eeTag.name],
343
348
summary: 'Get a user',
344
349
description: 'Fetches profile details for a single organization member by `userId`. Only organization owners can access this endpoint.',
345
350
request: {
@@ -357,13 +362,16 @@ export function createPublicOpenApiDocument(version: string) {
357
362
404: errorJson('User not found.'),
358
363
500: errorJson('Unexpected failure.'),
359
364
},
365
+
'x-mint': {
366
+
content: EE_LICENSE_KEY_NOTE,
367
+
},
360
368
});
361
369
362
370
registry.registerPath({
363
371
method: 'delete',
364
372
path: '/api/ee/user',
365
373
operationId: 'deleteUser',
366
-
tags: [eeUserManagementTag.name],
374
+
tags: [eeTag.name],
367
375
summary: 'Delete a user',
368
376
description: 'Permanently deletes a user and all associated records. Only organization owners can delete other users.',
369
377
request: {
@@ -381,13 +389,16 @@ export function createPublicOpenApiDocument(version: string) {
381
389
404: errorJson('User not found.'),
382
390
500: errorJson('Unexpected failure.'),
383
391
},
392
+
'x-mint': {
393
+
content: EE_LICENSE_KEY_NOTE,
394
+
},
384
395
});
385
396
386
397
registry.registerPath({
387
398
method: 'get',
388
399
path: '/api/ee/users',
389
400
operationId: 'listUsers',
390
-
tags: [eeUserManagementTag.name],
401
+
tags: [eeTag.name],
391
402
summary: 'List users',
392
403
description: 'Returns all members of the organization. Only organization owners can access this endpoint.',
393
404
responses: {
@@ -398,14 +409,17 @@ export function createPublicOpenApiDocument(version: string) {
398
409
403: errorJson('Insufficient permissions or entitlement not enabled.'),
399
410
500: errorJson('Unexpected failure.'),
400
411
},
412
+
'x-mint': {
413
+
content: EE_LICENSE_KEY_NOTE,
414
+
},
401
415
});
402
416
403
417
// EE: Audit
404
418
registry.registerPath({
405
419
method: 'get',
406
420
path: '/api/ee/audit',
407
421
operationId: 'listAuditRecords',
408
-
tags: [eeAuditTag.name],
422
+
tags: [eeTag.name],
409
423
summary: 'List audit records',
410
424
description: 'Returns a paginated list of audit log entries. Only organization owners can access this endpoint.',
411
425
request: {
@@ -430,6 +444,9 @@ export function createPublicOpenApiDocument(version: string) {
430
444
403: errorJson('Insufficient permissions or entitlement not enabled.'),
@@ -441,7 +458,7 @@ export function createPublicOpenApiDocument(version: string) {
441
458
version,
442
459
description: 'OpenAPI description for the public Sourcebot REST endpoints used for search, repository listing, and file browsing. Authentication is instance-dependent: API keys are the standard integration mechanism, OAuth bearer tokens are EE-only, and some instances may allow anonymous access.',
0 commit comments