curl -X POST https://auth.bundleup.io/connection \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "Yx8k2...", "redirect_uri": "https://app.example.com/callback"}'
const { connection_id } = await client.auth.getConnectionFromCode({
code,
redirectUri: 'https://app.example.com/callback',
});
connection = client.auth.get_connection_from_code(
code=code,
redirect_uri="https://app.example.com/callback",
)
connection = client.auth.get_connection_from_code(
code: code,
redirect_uri: 'https://app.example.com/callback'
)
{
"connection_id": "conn_abc123",
"external_id": "user_42",
"integration_id": "github"
}
{
"success": false,
"message": "Invalid request",
"errors": {
"code": ["Invalid or expired authorization code"]
}
}
{
"success": false,
"message": "Not authorized"
}
Auth API
Exchange a Code
Turn the one-time code from the authorization redirect into a connection ID.
POST
/
connection
curl -X POST https://auth.bundleup.io/connection \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "Yx8k2...", "redirect_uri": "https://app.example.com/callback"}'
const { connection_id } = await client.auth.getConnectionFromCode({
code,
redirectUri: 'https://app.example.com/callback',
});
connection = client.auth.get_connection_from_code(
code=code,
redirect_uri="https://app.example.com/callback",
)
connection = client.auth.get_connection_from_code(
code: code,
redirect_uri: 'https://app.example.com/callback'
)
{
"connection_id": "conn_abc123",
"external_id": "user_42",
"integration_id": "github"
}
{
"success": false,
"message": "Invalid request",
"errors": {
"code": ["Invalid or expired authorization code"]
}
}
{
"success": false,
"message": "Not authorized"
}
Call this from your backend after the user lands on your
redirect_uri with a code. It returns the new connection’s ID.
The code expires 5 minutes after it’s issued and can be used once.
Headers
string
required
Bearer YOUR_API_KEY. Must be a key from the same workspace that issued the code.Body
string
required
The
code query parameter from the redirect.string
required
The exact
redirect_uri used to start the flow.Response
string
The new connection’s ID. Store it, and send it as
BU-Connection-Id on requests.string | null
The
external_id passed when starting the flow, or null.string
The integration’s identifier, for example
github.Errors
400witherrors.code: the code has expired, was already used, was issued for a differentredirect_uri, or belongs to another workspace.400witherrors.redirect_uriorerrors.code: the field is missing.401: the API key is missing or not recognized.
curl -X POST https://auth.bundleup.io/connection \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "Yx8k2...", "redirect_uri": "https://app.example.com/callback"}'
const { connection_id } = await client.auth.getConnectionFromCode({
code,
redirectUri: 'https://app.example.com/callback',
});
connection = client.auth.get_connection_from_code(
code=code,
redirect_uri="https://app.example.com/callback",
)
connection = client.auth.get_connection_from_code(
code: code,
redirect_uri: 'https://app.example.com/callback'
)
{
"connection_id": "conn_abc123",
"external_id": "user_42",
"integration_id": "github"
}
{
"success": false,
"message": "Invalid request",
"errors": {
"code": ["Invalid or expired authorization code"]
}
}
{
"success": false,
"message": "Not authorized"
}
Was this page helpful?

