> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/developers/gitbook-api/api-reference/integrations/consume-an-integration-oauth-transaction.md).

# Consume an integration OAuth transaction

Consumes the OAuth transaction whose ID was received as the `state` of an OAuth callback. A transaction can be consumed once, by the integration that it was created for, and only with the authorization code that the user who started the connection confirmed in GitBook. Returns the installation the credentials must be written to, the PKCE code verifier, and a single-use grant to pass as `oauthTransaction` when writing the credentials.

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"tags":[{"name":"integrations","description":"Expand the capabilities of GitBook by connecting it with various external platforms—CRM, finding trackers, or CI/CD pipelines—through standardized integration endpoints.\n"}],"servers":[{"url":"{host}/v1","variables":{"host":{"default":"https://api.gitbook.com"}}}],"security":[{"integration":[]},{"integration-installation":[]}],"components":{"securitySchemes":{"integration":{"type":"http","scheme":"bearer"},"integration-installation":{"type":"http","scheme":"bearer"}},"parameters":{"integrationName":{"name":"integrationName","in":"path","required":true,"description":"Name of the integration.","schema":{"type":"string","pattern":"^[a-zA-Z0-9-_.]+$","maxLength":100}}},"schemas":{"ConsumeIntegrationOAuthTransaction":{"type":"object","properties":{"redirectUri":{"type":"string","description":"The exact `redirect_uri` sent to the provider's authorize and token endpoints."},"code":{"type":"string","description":"The authorization code received on the callback."}},"required":["redirectUri","code"]},"IntegrationOAuthTransaction":{"type":"object","properties":{"object":{"type":"string","enum":["integration-oauth-transaction"]},"id":{"type":"string"},"organization":{"type":"string","description":"ID of the organization of the installation."},"installation":{"type":"string","description":"ID of the installation the credentials must be written to."},"space":{"type":"string","description":"ID of the space whose installation the credentials must be written to."},"site":{"type":"string","description":"ID of the site whose installation the credentials must be written to."},"codeVerifier":{"type":"string","description":"PKCE code verifier, to send as `code_verifier` when exchanging the code."},"redirectUri":{"type":"string","description":"The validated redirect URI."},"grantExpiresAt":{"$ref":"#/components/schemas/Timestamp"}},"required":["object","id","organization","installation","codeVerifier","redirectUri","grantExpiresAt"]},"Timestamp":{"type":"string","format":"date-time"}},"responses":{"ForbiddenError":{"description":"Forbidden","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[403]},"message":{"type":"string"}},"required":["code","message"]}}}}}},"NotFoundError":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","properties":{"code":{"type":"integer","format":"int32","enum":[404]},"message":{"type":"string"}},"required":["code","message"]}}}}}}}},"paths":{"/integrations/{integrationName}/oauth-transactions/{transactionId}/consume":{"post":{"operationId":"consumeIntegrationOAuthTransaction","summary":"Consume an integration OAuth transaction","description":"Consumes the OAuth transaction whose ID was received as the `state` of an OAuth callback. A transaction can be consumed once, by the integration that it was created for, and only with the authorization code that the user who started the connection confirmed in GitBook. Returns the installation the credentials must be written to, the PKCE code verifier, and a single-use grant to pass as `oauthTransaction` when writing the credentials.","tags":["integrations"],"parameters":[{"$ref":"#/components/parameters/integrationName"},{"name":"transactionId","in":"path","required":true,"description":"ID of the OAuth transaction, as received in the `state` parameter","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsumeIntegrationOAuthTransaction"}}}},"responses":{"200":{"description":"The transaction has been consumed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationOAuthTransaction"}}}},"403":{"$ref":"#/components/responses/ForbiddenError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/developers/gitbook-api/api-reference/integrations/consume-an-integration-oauth-transaction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
