# Get your API key

Create a key on the account page. It is shown once, so copy it there.

Page: https://legivel.com/docs/api-key

## Create a key

1. ### Create an account

   Sign up at [/signup](https://legivel.com/signup) with your email. You can sign in with a magic link sent to that address or set a password.
2. ### Open the account page

   Go to [/account](https://legivel.com/account) and find the **API keys** section.
3. ### Create a key

   Click **New key**, give it a **Name** (for example `CI` or `laptop`) and click **Create**. The name is required; it is how the account page and the usage report tell keys apart.

   The full key appears once, under the text *Shown once. Copy it now.* Only a hash is stored, so the page cannot show it again after you leave.
4. ### Store it

   Put the key in an environment variable. The samples in these docs read `LEGIVEL_API_KEY`.

   ```bash
   export LEGIVEL_API_KEY="lgv_your_key_here"
   ```

## Managing keys

- An account can hold up to 10 keys. The 11th create is refused with a 400 and the code `API_KEY_LIMIT`; revoke one to make room.
- After creation the account page shows only the prefix and the first 8 characters of the key body. Use the name to tell keys apart.
- **Revoke** takes two clicks: the first turns the button into **Confirm revoke**, the second deletes the key.
- A revoked key is usually refused at once. Verified keys are cached for 60 seconds and a database trigger evicts the entry on delete, so the worst case is about a minute.
- Usage made with a key survives revocation. `GET /v1/usage` keeps the key's name in the per-key breakdown for the rest of the month, and the account page lists it as revoked.

The prefix names the environment

A production key starts with `lgv_`. A key that starts with `lgv_stg_` was minted on staging and is rejected by production.
