# Quickstart

You need a Sign API account. Every new account comes with a **test key**, so you can start
sending right away. Test envelopes behave like live ones, except that emails are stored instead
of sent and nothing is charged.

## 1. Get your test key

Sign in to the [dashboard](https://app.signapi.lumin.example) and open **API keys**, or run the CLI:

```sh
signapi login
signapi init        # writes SIGNAPI_KEY to .env in the current folder
```

Keys start with `key_test_` or `key_live_`. Send the key in the `X-API-Key` header on every
request. Never put a live key in client-side code.

## 2. Create an envelope

An envelope holds the documents to sign and the people who sign them. This one has one PDF and
one signer. The document contains the text `[[client_signature]]` where the signature goes, and
`places` says that this place is a signature for the recipient `client`:

```sh
curl https://api.signapi.lumin.example/v1/envelopes \
  -H "X-API-Key: $SIGNAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Consulting agreement",
    "documents": [
      {
        "url": "https://example.com/agreement.pdf",
        "places": [
          { "key": "client_signature", "type": "signature", "recipient_key": "client" }
        ]
      }
    ],
    "recipients": [
      { "type": "signer", "key": "client", "name": "Alex Doe", "email": "alex@example.com" }
    ]
  }'
```

Instead of a public URL you can [upload the file](https://docs.signapi.dev/api/CreateUpload) first and use the upload's
`url`. The response is the new envelope with `status: processing`. Sign API has already fetched and
checked the document: a problem with it comes back as an [error](https://docs.signapi.dev/errors) on this request.

## 3. Follow it

Within seconds the envelope moves to `in_progress` and the signer gets an email. In test mode the
email is stored, not sent: open the envelope in the dashboard to read it and follow the signing
link yourself.

Rather than polling, add a webhook endpoint in the dashboard and listen for
[`envelope.completed`](https://docs.signapi.dev/webhooks). While you develop, the CLI forwards test events to your machine:

```sh
signapi listen --forward-to http://localhost:3000/webhooks
```

## 4. Download the signed PDF

When every recipient has finished, the envelope is `completed` and its default deliverable, the
signed PDF with an audit log, is generated. Read it with
[Get an envelope](https://docs.signapi.dev/api/GetEnvelope) or [Get a deliverable](https://docs.signapi.dev/api/GetDeliverable); the
deliverable's `url` downloads the file and works for a short time, so fetch a new one each time.

## Next steps

- Already using SignatureAPI? Read [Switch from SignatureAPI](https://docs.signapi.dev/migrate).
- Write documents as Markdown or HTML instead of PDF: [Sign API extensions](https://docs.signapi.dev/extensions).
- Show the signing ceremony inside your app: [Embedded signing](https://docs.signapi.dev/embedded-signing).
- Go live: create a live key in the dashboard and buy credits. A live envelope costs one credit.
