Skip to content

Create an MCP connection

POST
/orgs/{orgId}/mcp-connections
curl --request POST \
--url https://example.com/api/v1/orgs/example/mcp-connections \
--header 'Content-Type: application/json' \
--cookie better-auth.session_token=<better-auth.session_token> \
--data '{ "bucketIds": [ "example" ], "deliveries": [ "gated" ], "maxTtlSeconds": 1, "name": "example", "auth": "bearer" }'

Creates an MCP connection endpoint ({appUrl}/mcp/{id}) using bearer or OAuth authentication. Requires member role or higher and mcpAllowed enabled on the org.

Requires a signed-in browser session; API tokens are rejected with 403.

orgId
required

Organization ID.

string
Media typeapplication/json
object
bucketIds

Restrict token access to specific bucket IDs, or null/omit for an org-wide token.

Any of:
Array<string>
deliveries

Delivery modes this token may mint (defaults to ["gated"]).

Array<string>
>= 1 items
Allowed values: gated proxied
maxTtlSeconds

Maximum share link lifetime in seconds (60 to 31,536,000, default 604,800).

integer
>= 60 <= 31536000
name
string
>= 1 characters
auth

Authentication mode (bearer returns a one-time secret; oauth uses browser OAuth approval).

string
Allowed values: bearer oauth

Created MCP connection ID, endpoint URL, and one-time secret (for bearer auth)

Media typeapplication/json
object
id
required
string
secret
required
Any of:
string
url
required
string

Example generated

{
"id": "example",
"secret": "example",
"url": "example"
}

Invalid request input or rule violation.

Media typeapplication/json

Error returned when request input fails schema validation or violates a domain rule.

object
code
required
string
Allowed values: BAD_REQUEST
data
object
issues
required

Field-level validation failures, present when schema validation fails.

Array<object>
object
message
required
string
path
required

Dot-separated field path.

string
message
required

Human-readable error explanation.

string

Example

{
"code": "BAD_REQUEST"
}

Authentication required or credentials invalid.

Media typeapplication/json

Standard REST error envelope.

object
code
required

Machine-readable error code.

string
data

Optional structured error details.

message
required

Human-readable error explanation.

string

Example generated

{
"code": "example",
"data": "example",
"message": "example"
}

Insufficient role, bucket grant, or token scope.

Media typeapplication/json

Standard REST error envelope.

object
code
required

Machine-readable error code.

string
data

Optional structured error details.

message
required

Human-readable error explanation.

string

Example generated

{
"code": "example",
"data": "example",
"message": "example"
}

Unexpected server error. Quote data.requestId when you report it.

Media typeapplication/json

Error returned when Sendcrate or one of its providers fails (5xx).

object
code
required
string
Allowed values: INTERNAL_SERVER_ERROR PROVIDER_FAILED
data
object
debug

Error chain with stack traces. Present only when the server runs in development mode.

Array
requestId

Request reference to quote when you report the error.

string
message
required

Human-readable error explanation.

string

Example

{
"code": "INTERNAL_SERVER_ERROR"
}