> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cedarai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API clients

> Create expiring, carrier-scoped API keys that can call only the Cedar API endpoints you choose.

An **API client** is a named integration with its own API key. You decide which Cedar API endpoints it can call, which
Cedar users it may act as, and when its key expires. Use API clients for system-to-system integrations instead of
sharing a person's login.

> [!NOTE]
>
> API clients issue keys for Cedar's public APIs, the same APIs described in the
> [API documentation](https://docs.cedarai.com/user-docs/api-reference/introduction.md). You can also create keys in the Admin Portal; see
> [Tools and API keys](https://docs.cedarai.com/user-docs/admin/tools-api-keys.md) for how the two compare.

## The API clients list

Open **API** in the sidebar.⁠‌​‌​​‌​​​‌‌‌​​‌‌‌‌​‌​‌‌​⁠ The **API clients** page lists every client for the selected carrier, with the API
families it can call, its current key (by its last characters) and expiry, and its status.

![API clients page with name, access, credential, and status columns and a need attention count](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-clients-list.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=79927323ebe81cc8ee1a242ecbc2857c)

API clients for a carrier, with clients that need attention flagged

The **need attention** count at the top includes clients that:

* show **Action required**;
* have no working key, shown as **Credential expired** or **Credential revoked**;
* have **No assumed users**;
* have a key that expires within 14 days, shown as **Expires in N days**.

## Create an API client

Select **Create API client**. The **Steps** panel on the right tracks the five steps.

**1. Client details**

Enter a **Client name** that says what the integration is for, such as "Nightly inventory export". The **Carrier** is
the one selected in the sidebar; the key works only for that carrier. Choose a **Credential expiry**. The key works
through the end of that day in your time zone. The default is 90 days from today and the maximum is 365 days, unless
your organization's credential policy sets other limits.

![Create API client form with client name, carrier, and credential expiry](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-create-details.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=47160cb2b3c1dbadae38cfc48d2b4935)

Name the client and choose when its key expires

**2. API access**

Choose only the endpoints the integration needs. Endpoints are grouped by API family, and you can search by family
or endpoint name. Each endpoint shows its HTTP method, path, a short description, and a **Documentation** link.
Select **More** under a description to read all of it, and **Less** to fold it again. Use the checkbox next to a
family name to select every endpoint in it. The **Selected access** panel summarizes your choice.

![Select API access step with three Railcar API endpoints checked and the Selected access summary](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-create-access.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=4ba707d109a170fc2928c8761f5b49ce)

Select the endpoints the client may call

**3. Assumed users**

Every API call acts on behalf of a Cedar user, called the **assumed user**. Search for the users this client may act
as and select them. Alternatively, link a **Source group** to keep the list in sync with the members of one Cedar user
group. You can continue without any, and add them later from the client's page, but the client's calls need one.

![Assumed users step with Integration Service Account selected and an empty Source group search](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-create-users.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=655c696588a8bf14e465c79659b75400)

Choose the Cedar users the client may act as

**4. Review and create**

Check the carrier, expiry, endpoints, and assumed users, then select **Create API client**.

**5. Save credential**

The new key is shown **once**. Select **Copy credential** and store it in your secret manager. Tick **I saved the
credential in an approved secret manager**, then select **Finish**.

The **Starter request** is a `curl` command to try the key with. It sends the key in the `x-arms-api-key` header and
an assumed user in the `x-arms-assume-user` header, with `CEDAR_ASSUME_USER` set to the first assumed user you
picked and your carrier's ID filled in. If it shows `<endpoint-path>`, replace that with an endpoint the client may
call. The command reads the key from `$CEDAR_API_KEY`, so the key itself is never part of it.

![Save this credential now panel with the credential, the starter request, and the confirmation checkbox](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-credential.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=7c0c0619cac70346b4f403feff966c92)

The key is shown once. It is cleared when you leave the page.

> [!WARNING]
>
> Cedar can't show the key again after you leave this screen. If it's lost, rotate the credential to get a new one.

### Available API families

Railcar, Waybill, Work Order, Bookings, Charges, Shipper Invoices, Shipper Quotes, Truck Load Tender, Network Structure,
and Notes. Which endpoints you can choose depends on Cedar's published API catalog; an endpoint marked **Deprecated** is
being retired and shouldn't be used for new integrations.

## Call the API with your key

Send the key in the `x-arms-api-key` header and the email of one of the client's assumed users in the
`x-arms-assume-user` header.

```bash theme={null}
export CEDAR_API_KEY="<your key>"

curl -X POST "https://api-lg.arms.cedarai.com/ims/equipment/inventory?carrierId=<carrier ID>" \
  -H "x-arms-api-key: $CEDAR_API_KEY" \
  -H "x-arms-assume-user: integration-bot@example.com" \
  -H "Content-Type: application/json" \
  --data '{"pageSize": 20}'
```

`carrierId` is your carrier's numeric ID. The **Starter request** shown with a new key has it filled in, for example
`export CARRIER_ID="9001"` for DEMO · Demo Rail Group.

* **Use the right region.** Keys are region-specific. Carriers in the EU use the `cedarai.se` hostnames instead of
  `cedarai.com`. See [Regions](https://docs.cedarai.com/user-docs/api-reference/introduction.md#regions).
* **Permissions come from the assumed user.** A call succeeds only if the endpoint is selected on the client **and** the
  assumed user's own Cedar roles allow it.
* **Find each endpoint's URL and body** from the **Documentation** link in Data Depot or the
  [API documentation](https://docs.cedarai.com/user-docs/api-reference/introduction.md).

## Manage an API client

Select a client in the list to open its page, headed with the client's name.

![Yard inventory sync API client page with Edit access, Rotate credential, the selected API access by family, and Client details](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-detail.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=6431f4791225db2a0ae5724bc8245dbb)

An API client's page

### Change the endpoints

Select **Edit access**, change the selected endpoints, and select **Save changes**. The bar at the bottom summarizes the
change, for example "Access will change from 4 to 6 endpoints". The key doesn't change.

### Manage assumed users

The **Assumed users** section shows how many users can call the client's APIs.

* Under **Direct members**, select **Add users** or **Remove** next to a user.
* Under **Source group**, select **Link source group** to sync membership from one Cedar user group. A linked group shows
  **Synced**, or **Sync pending** while changes are applied.⁠‌​‌​​‌​​​‌‌‌​​‌‌‌‌​‌​‌‌​⁠ You can **Replace** or **Unlink** it.

If a client has no assumed users, it shows **No assumed users**. Its calls can't act as anyone, so add at least one.

![Assumed users with a direct member and a synced source group, and Credentials with active, retiring, revoked, and expired keys](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-detail-credentials.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=3046ccd653a1e9ae2f007129bec00569)

Assumed users and the client's credentials

### Rotate the credential

Rotate before a key expires, or whenever you need a new one.

**1. Start the rotation**

Select **Rotate credential**. Choose the **Replacement expiry** (the new key works through the end of that day) and
the **Overlap hours** (24 by default, up to 168).

**2. Save the new key**

Select **Create replacement**. The new key is shown once; save it the same way as before.

**3. Switch your integration**

Both keys work during the overlap. Update your integration to the new key before the overlap ends. After that the old
key, shown as **retiring**, stops working automatically.

![Rotate credential dialog with Replacement expiry and Overlap hours](https://mintcdn.com/cedaraiinc/x6rnIZGf3PCPR7Z-/images/data-depot/api-client-rotate.png?fit=max\&auto=format\&n=x6rnIZGf3PCPR7Z-\&q=85\&s=b9b4de72f0960ce750f1f1cd8c044a68)

Rotate with an overlap so your integration never loses access

If every key has expired or been revoked, the client shows **Credential expired** (or **Credential revoked**) and its API
calls fail. The button then reads **Issue new credential**. There's no old key to overlap with, so you choose only an
**Expiry** and select **Issue credential**. Save the new key and update your integration with it.

### Revoke a credential

Under **Credentials**, select **Revoke** next to a key, then **Revoke credential** to confirm. The key stops working
immediately. This can't be undone. If it's the client's only working key, Data Depot warns you that the client's API
calls will fail until you issue a new one.

### Delete the client

Select **Delete API client**, type the client's name, and select **Delete API client** again to confirm. This revokes
every key the client has and removes its API access.

### Credential statuses

| Status | Meaning |
| - | - |
| **Active** | The key works |
| **Retiring** | A replacement exists; this key works until the overlap ends, shown as **Stops working** |
| **Revoked** | The key was revoked and no longer works |
| **Expired** | The key passed its expiry date |

Each key also shows when it was **Last used**, which helps you confirm an integration has switched to a new key.

### Client details

The **Client details** panel shows when the client was created. Open **Technical details** for the client ID and the
API catalog version the client was built against. Data Depot manages a user group, role, and binding in the Admin
Portal for each client; **Technical details** links to each of them.

## When a client needs attention

* **Action required.** A change didn't finish applying. Select **Retry cleanup and reconciliation** to try again. This
  needs the permission to delete API clients.
* **Credential expired — API calls are failing.** The client has no working key. Select **Issue new credential**. See
  [Rotate the credential](#rotate-the-credential).
* **Credential delivery could not be confirmed.** The connection dropped while a new key was being created. Select
  **Check request status**.⁠‌​‌​​‌​​​‌‌‌​​‌‌‌‌​‌​‌‌​⁠ If the key can't be shown, select **Revoke unseen credential and generate replacement** to get
  a new one safely.
* **The API catalog changed.** If Cedar retires an endpoint while you're creating or editing a client, Data Depot asks
  you to review the updated selection.

## Related pages

* [API documentation](https://docs.cedarai.com/user-docs/api-reference/introduction.md)
* [Tools and API keys](https://docs.cedarai.com/user-docs/admin/tools-api-keys.md)
* [Access and permissions](https://docs.cedarai.com/user-docs/data-depot/access.md)


## Related topics

- [API Introduction](https://docs.cedarai.com/user-docs/api-reference/introduction.md)
- [Tools & API Keys](https://docs.cedarai.com/user-docs/admin/tools-api-keys.md)
- [Access and permissions](https://docs.cedarai.com/user-docs/data-depot/access.md)
- [Use Cedar data in Databricks](https://docs.cedarai.com/user-docs/data-depot/databricks.md)
- [Choosing the right option](https://docs.cedarai.com/user-docs/data-depot/choosing.md)
