API keys often act as both a unique identifier and a secret token for authentication. Usually, an API key has a set of access rights specific to the identity associated with the API key.
You can log in to Content Rest APIs and wchtools by creating an API key. The API key is linked to your account whether the account has federated authentication or not.
Note: When you get an Acoustic ID, you'll need to generate new API keys to replace your existing API keys. Each API Key generated is tied to a specific subscription, and you cannot use an API key generated in one subscription to access another subscription. You also cannot use the same API key to connect to multiple clients.
Generate API key
Generate an API key from the My Acoustic page.
- Click User menu > My Acoustic to open the My Acoustic page. Hover over the subscription card that you want the API Keys for, open the options menu and click Manage or View details.
- The Subscription details page opens. Click the Subscription tab from the side navigation to access the API keys tab.
- Go to the API keys page and click Generate API key.
- Provide a name and description for your key for easy identification and click Generate.
Note: You can rename and edit the description later from the API keys page.
- Content automatically generates the API key for you. Make sure you copy the generated API key in a secure location.
Note: The API keys will expire and stop working if you do not use them for 90 days.
If you created your API key before 07 Mar 2023 and did not use it, it would expire after 30 days.
Use the API keys to log in with Content's CLI tool
- Initialize the wchtools with the following command
wchtools init
. - Enter the API URL for your Content subscription. For example, API URL
https://content-cms.com/api/cd73e279-a2c9-47a3-8b41-6ae3933c0ec6
- Enter AcousticAPIKey as the username. The CLI saves the configuration settings for wchtools.
Note: The username AcousticAPIKey is case-sensitive.
- Provide the API Key you generated for this subscription as the password. You can now work with Content using wchtools CLI.
Use the API keys to log in with the API
For logging in with the APIs, use the following curl commands:
curl -v -u AcousticAPIKey:{insert your API key value here} https://content-cms.com/api/login/v1/basicauth --header 'x-ibm-dx-tenant-id:{insert your tenant-id here]'
Where the string AcousticAPIKey
is your user name, and you must provide your API key value that you generated.
Note: The username AcousticAPIKey is case-sensitive.
The response to the login request contains a Set-Cookie header
containing the proper x-acoustic-auth-token
value for the user to set in future API requests. The x-acoustic-auth-token
header value is used to authenticate subsequent requests.
Authentication for webhooks
Content provides a more convenient alternate method to authenticate, which can be useful when using applications such as webhooks. You can avoid the step of sending in a login request separately and can set the basic-auth header directly as a part of any API request you send to Content. The response includes the Set-Cookie
headers
containing the proper x-acoustic-auth-token
value used to authenticate subsequent requests you send.
For example, you can set your credentials as a basic-auth header in an authoring request as follows:
curl -v -u AcousticAPIKey:{insert your API key value here} API URL or DELIVERY URL
Note: You can get the API URL or Delivery URL for your subscription from the Developer > URL information page.
For example,
API URL: https://content-us-1.content-cms.com/api/<id>
DELIVERY URL: https://content-us-1.content-cms.com/<id>