Skip to main content

Managing API keys (X-Cart 5.6.x)

Create and manage the secret keys that give integrations and custom apps access to your store's data through X-Cart's API.

A
Written by Anna Verbichenko

An API key is a secret key that allows you to use the Admin API and the Storefront API to get or change information in your store: products, categories, user profiles, orders, and so on. All keys are managed from one page in the Admin area.

You can access this page from Settings > API. The page itself is titled API Keys.

The Admin API and Storefront API links in the page's intro text lead to the API pages of your own store (/api and /api?section=storefront).


Key scopes

Each key has a scope that defines what it can do:

  • Admin API - read only: lets an integration read store data, but not change it. This is the default.

  • Admin API - read & write: lets an integration read and change store data.

  • Storefront API: for the Storefront API.

Give an integration the narrowest scope it needs. Treat read & write keys like an administrator password: anyone who has the key can change your store.


Creating an API key

  1. Open the API Keys page and click Add API key. A new row appears in the table. You can add one key at a time.

  2. Enter a Name that tells you what the key is used for, for example "Accounting sync".

  3. Select the Scope.

  4. Pick the Expires on date. It is required: the earliest date is today, the latest is one year from today.

  5. Click Save changes.

  6. In the Save API Key window, click Copy and store the key in a secure place, for example a password manager. Then click I've saved key.

The key is shown only once.

X-Cart does not keep the key itself, only its protected hash, so it cannot be shown again or recovered. If you lose a key, delete it and create a new one.

Keys are generated automatically (128 characters); you cannot enter your own.


The list of keys

The table shows all keys of your store:

  • Name and Scope.

  • Created on and Expires on.

  • Last usage: the date the key was last used (updated once a day), or Never.

Keys that X-Cart creates for its own internal needs are not shown in this list.

For each key you can:

  • Switch it off and on with the power icon (green: on, grey: off).

  • Delete it with the trash icon. An integration that uses a deleted key loses access immediately.

Both changes are applied after you click Save changes.

You cannot change the expiration date of an existing key. To extend access, create a new key and update your integration to use it.


Key expiration

When a key expires, it stops working immediately, and any integration that uses it loses access to your store. A switched-off key does not work either.

X-Cart checks your keys once a day. If a key expires within a week, X-Cart emails the store administrator (the first address in the Site administrator field of your store settings) with the subject "Action required: API keys are about to expire". The email lists the keys that are about to expire and their dates. Each key is reported once, and the notification cannot be disabled, because an expired key stops working immediately.

The notification is listed as API keys are about to expire in Settings > Email Notifications.

An expired key you created stays in the list for one more month, so you can see why an integration stopped working, and is then removed automatically.

To keep an integration running, create a new key before the old one expires and update the integration.


Zapier

If your store has the Zapier add-on enabled, the access token is no longer set in the add-on's settings. The settings page shows a note instead: create a key on the API Keys page with scope Admin API - read only or Admin API - read & write, and use it in Zapier.


Existing keys

If your store used API keys before this page appeared, they were moved to the API Keys page during the update:

  • Storefront token (scope Storefront API), API key (only read) (Admin API - read only) and API key (read/write) (Admin API - read & write) come from the three former API settings. If the same token was entered in several of those settings, you get a single key with the narrowest of the scopes.

  • If you used the Zapier add-on, its access token became the key Zapier Access Token with scope Admin API - read & write.

Moved keys get an expiration date 12 months after the update. If a former token was short (less than 32 characters), the key lives only one month: replace it with a new generated key before it expires. Keys that were tied to administrator profiles were not moved: such keys no longer exist, and you need to create new ones on this page.

Keep track of the expiration dates of the moved keys and create new keys before they expire.


FAQ

Q: Where can I read about the API itself?


Can't find answers you're looking for?

Email us at support@x-cart.com. We will be happy to help!


Related articles

Did this answer your question?