# Company API

> Manage employees from your own systems with a company API key - list people, create a person with teams, get a one-time sign-in link, block and unblock. How it differs from a workspace's own API token, with curl examples.

Source: https://eggent.ai/docs/enterprise-api/

The company API lets your systems manage people: a developer portal such as Backstage, an HR system, an onboarding script.

## A company API key {#keys}

Section **API keys** in the [admin console](https://eggent.ai/docs/enterprise-console.md) creates a key that starts with `eggk_`.

- It is shown once. Eggent keeps only its hash.
- The list shows when each key was last used.
- A key can be revoked at any moment.

**Not to be confused with a workspace's API token.** The token in **Settings → API** inside one workspace talks to that one agent: sends it a message, as described in [API for integrations](https://eggent.ai/docs/external-api.md). A company key manages people across the company and cannot talk to anyone's agent.

## Requests {#requests}

Every request carries `Authorization: Bearer eggk_…` and goes to the console's address.

```bash
# The company and its people
curl -H "Authorization: Bearer $EGGENT_KEY" https://eggent.company.tld/api/org/<company>

# Create a person
curl -X POST -H "Authorization: Bearer $EGGENT_KEY" -H "Content-Type: application/json" \
  -d '{"name": "Anna", "login": "anna@company.tld", "teams": ["Backend"]}' \
  https://eggent.company.tld/api/org/<company>/members

# A one-time sign-in link for that person
curl -X POST -H "Authorization: Bearer $EGGENT_KEY" \
  https://eggent.company.tld/api/org/<company>/members/<id>/signin-link
```

The answer to creating a person carries their `id`. The sign-in link works once.

## Blocking and unblocking {#block}

```bash
curl -X POST -H "Authorization: Bearer $EGGENT_KEY" https://eggent.company.tld/api/org/<company>/members/<id>/block
curl -X POST -H "Authorization: Bearer $EGGENT_KEY" https://eggent.company.tld/api/org/<company>/members/<id>/unblock
```

Blocking works as in the console: open sessions end and the workspace stops ([Blocking a person](https://eggent.ai/docs/enterprise-console.md#block)).

## A button in your portal {#portal}

With [company sign-in](https://eggent.ai/docs/enterprise-sso.md) on, a portal button does not need the API at all: link it to the company's SSO sign-in address (`https://eggent.company.tld/sso/<company>/login`). The person signs in with the company account and their workspace is created on the first sign-in.

Use the API when the portal should create the person ahead of time, with their teams, for example from a Backstage scaffolder action that calls `POST /api/org/<company>/members` and hands the person a sign-in link.

Every call made with a company key is recorded in the [activity log](https://eggent.ai/docs/enterprise-audit.md).
