info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
OpenAPI specs for the Marketplace APIs are available at [Marketplace interactive API documentation](https://customers.staging.gitlab.com/openapi_docs/marketplace).
## Access the Marketplace API
To access the Marketplace API you need to:
- Request access from GitLab.
- Retrieve an OAuth access token.
Marketplace API endpoints are secured with [OAuth 2.0](https://oauth.net/2/). OAuth is an authorization framework
that grants 3rd party or client applications, like a GitLab Partner application, limited access to resources on an
HTTP service, like the Customers Portal.
OAuth 2.0 uses _grant types_ (or _flows_) that describe how a client application gets authorization in
the form of an _access token_. An access token is a string that the client application uses to make authorized requests to
the resource server.
The Marketplace API uses the `client_credentials` grant type. The client application uses the access token to access its
own resources, instead of accessing resources on behalf of a user.
- Make a POST request to the [`/oauth/token`](https://customers.staging.gitlab.com/openapi_docs/marketplace#/marketplace/post_oauth_token) endpoint with the following required parameters:
| `client_id` | string | yes |ID of your client application record on the Customers Portal. Received from GitLab. |
| `client_secret` | string | yes |Secret of your client application record on the Customers Portal. Received from GitLab. |
| `grant_type` | string | yes |Specifies the type of credential flow. Use `client_credentials`. |
| `scope` | string | yes |Specifies the level of access. Use `marketplace.order:read` for read-only access. Use `marketplace.order:create` for create access. |
If the request is successful, the response body includes the access token that you can use in subsequent requests. For an example of a successful
response, see the [Marketplace interactive API documentation](https://customers.staging.gitlab.com/openapi_docs/marketplace)
If the request is unsuccessful, the response body includes an error and error description. The errors can be:
| `externalSubscriptionId` | string | yes | ID of the subscription on the GitLab Partner system. |
| `tradingPartnerId` | string | yes | ID of the GitLab Partner account on the Customers Portal. |
| `customer` | object | yes | Information about the customer. Must include company name. Contact must include `firstName`, `lastName` and `email`. Address must include `country`. |
| `orderLines` | array | yes | Specifies the product purchased. Must include `quantity` and `productId`. |
If the request is successful, the response body includes the newly created subscription number. For an example of a full request body,
see the [Marketplace interactive API documentation](https://customers.staging.gitlab.com/openapi_docs/marketplace).
If the subscription creation is unsuccessful, the response body includes an error message with details about the cause of the error.