Connections
The 10 operations under connections, as typed calls on the generated REST client.
Connections
Available from @codespar/sdk 0.12.0, which is not on npm yet. The published version today is 0.11.0, and it has no cs.api; 0.12.0 is on the main branch of codespar-core. The examples below are not compiled against the installed package for that reason.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { CodeSpar } from "@codespar/sdk";
const cs = new CodeSpar({ apiKey: process.env.CODESPAR_API_KEY });GET /v1/connections
/v1/connectionsList the connections in this project
const result = await cs.api.get("/v1/connections");Parameters, body and every documented response: GET /v1/connections in the HTTP reference.
POST /v1/connections
/v1/connectionsRegister a provider key, or rotate the one already there
const r = await cs.api.response("post", "/v1/connections", {
body: {
server_id: "srv_0000000000000000",
secret: "string",
display_name: "Example",
user_id: "user_0000000000000000",
connection_metadata: {}
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/connections in the HTTP reference.
GET /v1/connections/engine/{run_id}/status
/v1/connections/engine/{run_id}/statusPoll a browser-driven signup run
const result = await cs.api.get("/v1/connections/engine/{run_id}/status", {
path: {
run_id: "run_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/connections/engine/{run_id}/status in the HTTP reference.
POST /v1/connections/start
/v1/connections/startBegin the Connect Link OAuth flow for a provider
const result = await cs.api.post("/v1/connections/start", {
body: {
server_id: "srv_0000000000000000",
user_id: "user_0000000000000000",
redirect_uri: "https://example.com/hook",
scopes: "string"
}
});Parameters, body and every documented response: POST /v1/connections/start in the HTTP reference.
POST /v1/connections/subaccount/{id}/revoke
/v1/connections/subaccount/{id}/revokeRevoke a provisioned subaccount and try to delete it upstream
const r = await cs.api.response("post", "/v1/connections/subaccount/{id}/revoke", {
path: {
id: "subaccount_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}Parameters, body and every documented response: POST /v1/connections/subaccount/{id}/revoke in the HTTP reference.
GET /v1/connections/subaccount/{id}/status
/v1/connections/subaccount/{id}/statusRead whether a provisioned subaccount can transact yet
const result = await cs.api.get("/v1/connections/subaccount/{id}/status", {
path: {
id: "subaccount_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/connections/subaccount/{id}/status in the HTTP reference.
GET /v1/connections/{id}
/v1/connections/{id}Read one connection
const result = await cs.api.get("/v1/connections/{id}", {
path: {
id: "conn_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/connections/{id} in the HTTP reference.
DELETE /v1/connections/{id}
/v1/connections/{id}Delete a revoked connection for good
const result = await cs.api.delete("/v1/connections/{id}", {
path: {
id: "conn_0000000000000000"
}
});Parameters, body and every documented response: DELETE /v1/connections/{id} in the HTTP reference.
POST /v1/connections/{id}/revoke
/v1/connections/{id}/revokeRevoke a connection and destroy its stored credential
const result = await cs.api.post("/v1/connections/{id}/revoke", {
path: {
id: "conn_0000000000000000"
}
});Parameters, body and every documented response: POST /v1/connections/{id}/revoke in the HTTP reference.
PUT /v1/connections/{id}/webhook-secret
/v1/connections/{id}/webhook-secretSeed or rotate the secret that verifies this provider's inbound webhooks
const result = await cs.api.put("/v1/connections/{id}/webhook-secret", {
path: {
id: "conn_0000000000000000"
},
body: {
secret: "string"
}
});Parameters, body and every documented response: PUT /v1/connections/{id}/webhook-secret in the HTTP reference.