Create an API Client for your Project
You must first set up an API Client before your applications can interact with your Project. An API Client includes authentication information and permission scopes to determine the endpoints the API Client can interact with.
Objectives of this guide
By the end of this guide you will have:
Create an API Client
-
In the Merchant Center, click Settings > Developer settings.
-
On the API clients tab, click Create new API client. On the New API client page, follow these steps:
-
Enter a name for your API client. The name does not affect how the API functions.
-
Select the scopes for your API Client. To provide the API Client with complete access, click the drop-down and select Admin client. To follow security best practices, we recommend to keep the scopes to the minimum that is needed.
-
Click Create API client. On saving, your API Client information is displayed in the Client credential flow section.The API Client information is only displayed once. Ensure to save the project_key, client_id, secret, scope, API URL, and Auth URL before leaving or closing this page.
-
Optional: At this stage, you can request an access token that you need to make API calls to your Project with a cURL command. If you have cURL installed on your machine, you can copy the command to your clipboard and run it in your terminal. The access token is valid for 48 hours.If you do not request a token at this stage, you can obtain it later with your saved API Client information by following the steps in Make your first API call. Please also save your API Client information to avoid losing it.
-
Save your API Client information as explained in the next section for use in your applications.
Save the API Client information
To use a commercetools SDK or an HTTP client such as Postman or Bruno, download the API Client information in a format suitable for your SDK or client.
Alternatively, you can copy these configurations to your clipboard and paste them into your existing configuration files.
.env
file.-
From the drop-down, select Environment Variables (.env) and click the download icon.
-
Locate the downloaded file. Its filename contains your Project key and API Client name, for example:
{projectKey}_{API client name}.env
.Optional: To use the downloaded file in your development project, rename it to.env
and move it to your code base. -
Open the downloaded file with any text or code editor. You'll need the environment variables in this file to retrieve the access token.
Next steps
Now that you have your API Client set up, you are ready to retrieve your access token and make your first API call to your Project.