Exchange the code for the user reference
OpenAPI JSONconst url = 'https://api.eu.apigami.com/connect/token';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"grant_type":"authorization_code","code":"q4HcV7yO1c3uXn0mJ2rT8kLwZp5sA6dE9fG0hI1jK2l","code_verifier":"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk","redirect_uri":"https://example.com/apigami/callback"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.eu.apigami.com/connect/token \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "grant_type": "authorization_code", "code": "q4HcV7yO1c3uXn0mJ2rT8kLwZp5sA6dE9fG0hI1jK2l", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "redirect_uri": "https://example.com/apigami/callback" }'Your server trades the code the user came back with, within 60 seconds and once, for the user’s user_ref. Send the code_verifier whose challenge opened the connection and the same redirect_uri, character for character. Any failure is invalid_grant and burns the code: start a new connection.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Optional; anything else is unsupported_grant_type.
Example
{ "grant_type": "authorization_code", "code": "q4HcV7yO1c3uXn0mJ2rT8kLwZp5sA6dE9fG0hI1jK2l", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "redirect_uri": "https://example.com/apigami/callback"}Responses
Section titled “Responses”The user is connected to your app. Save user_ref; install_ref is the browser the user connected from, or null.
object
The language the person reads Apigami in, which they choose in their account: en, fr, es or de. Write to them in it.
The person’s name and email, when the version judging declares identity and the person granted it to an application of your group that reaches yours through applications of your group only; or, your application declared optional by an application of another group, once the person authorized its own line there, reached through the two groups only, their email verified, read with your key or from your own page, never in a call from that application; null otherwise. Never in an event. Judged on your production.
object
The name the person gave, null while they have none: never their email in its place.
object
The name the user gave that browser.
Example
{ "user_ref": "usr_3f9c1a0e7b2d4c58a61e9f0b2d7c4e13", "locale": "fr", "identity": null, "install_ref": "ins_8b1e4f2a9c3d4e5f8a7b6c5d4e3f2a1b", "installs": [ { "install_ref": "ins_8b1e4f2a9c3d4e5f8a7b6c5d4e3f2a1b", "label": null, "online": true } ]}The code cannot be exchanged.
object
Present and true when the approval window is open and the user has not answered within 45 s.
On consent requested and no grant from emails.send or ai.generate: the permission the user never decided, or refused. Absent for a site.
On no grant: the page of the user’s Apigami space where they allow it again; send them there.
On consent requested, in place of permission: the bare app_id of each application whose terms or subprocessors the user has yet to agree to, unlike the boxes of GET /apps/{app_id}. Only the connect page asks it: send them to connect_url, or to one of your pages.
With terms, when the user agrees under your application: your install link, where they tick the boxes still to tick.
Examples
{ "error": "invalid_grant"}{ "error": "unsupported_grant_type"}Missing, malformed or revoked API key.
object
Present and true when the approval window is open and the user has not answered within 45 s.
On consent requested and no grant from emails.send or ai.generate: the permission the user never decided, or refused. Absent for a site.
On no grant: the page of the user’s Apigami space where they allow it again; send them there.
On consent requested, in place of permission: the bare app_id of each application whose terms or subprocessors the user has yet to agree to, unlike the boxes of GET /apps/{app_id}. Only the connect page asks it: send them to connect_url, or to one of your pages.
With terms, when the user agrees under your application: your install link, where they tick the boxes still to tick.
Example
{ "error": "bad client credentials"}