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

# Create API Key

Use this API to create a new API key for a workspace.

<Info>
  This endpoint uses **workspace-level auth**: pass `x-velt-workspace-id` and `x-velt-workspace-auth-token` (from the Create Workspace response) as headers.
</Info>

<Note>
  This API currently supports creating **`testing`** API keys only.
</Note>

# Endpoint

`POST https://api.velt.dev/v2/workspace/apikey/create`

# Headers

<ParamField header="x-velt-workspace-id" type="string" required>
  Your Workspace ID.
</ParamField>

<ParamField header="x-velt-workspace-auth-token" type="string" required>
  Your workspace [Auth Token](/security/auth-tokens).
</ParamField>

# Body

#### Params

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="ownerEmail" type="string" required>
      Email address of the API key owner.
    </ParamField>

    <ParamField body="type" type="string" required>
      API key type. Currently only `"testing"` is supported.
    </ParamField>

    <ParamField body="createAuthToken" type="boolean">
      Whether to create an auth token along with the API key. Recommended: `true`.
    </ParamField>

    <ParamField body="apiKeyName" type="string">
      Display name for the API key.
    </ParamField>

    <ParamField body="allowedDomains" type="string[]">
      List of domains allowed to use this API key.
    </ParamField>

    <ParamField body="addLocalHostToAllowedDomains" type="boolean">
      Whether to automatically add localhost to allowed domains.
    </ParamField>

    <ParamField body="useEmailService" type="boolean">
      Whether to enable the email service for this API key.
    </ParamField>

    <ParamField body="useWebhookService" type="boolean">
      Whether to enable the webhook service for this API key.
    </ParamField>

    <ParamField body="emailServiceConfig" type="object">
      Configuration object for the email service. See [Update Email Config](/api-reference/rest-apis/v2/workspace/emailconfig-update) for the full schema.

      <Expandable title="properties">
        <ParamField body="type" type="string">
          Email service provider type. Accepted values: `"default"` or `"sendgrid"`.
        </ParamField>

        <ParamField body="apiKey" type="string">
          API key for the email service provider (e.g., your SendGrid API key).
        </ParamField>

        <ParamField body="fromEmail" type="string">
          Sender email address.
        </ParamField>

        <ParamField body="fromCompany" type="string">
          Sender company name.
        </ParamField>

        <ParamField body="commentTemplateId" type="string">
          SendGrid template ID for comment notification emails.
        </ParamField>

        <ParamField body="tagTemplateId" type="string">
          SendGrid template ID for tag/mention notification emails.
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="webhookServiceConfig" type="object">
      Configuration object for the webhook service. See [Update Webhook Config](/api-reference/rest-apis/v2/workspace/webhookconfig-update) for the full schema.

      <Expandable title="properties">
        <ParamField body="authToken" type="string">
          Auth token sent with each webhook request for verification.
        </ParamField>

        <ParamField body="rawNotificationUrl" type="string">
          URL to receive raw (unprocessed) webhook notifications.
        </ParamField>

        <ParamField body="processedNotificationUrl" type="string">
          URL to receive processed webhook notifications.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

# Example Request

```JSON theme={null}
{
  "data": {
    "ownerEmail": "owner@example.com",
    "type": "testing",
    "createAuthToken": true
  }
}
```

# Example Response

#### Success Response

```JSON theme={null}
{
  "result": {
    "status": "success",
    "message": "API key created successfully.",
    "data": {
      "apiKey": "your_new_api_key"
    }
  }
}
```

#### Failure Response

```JSON theme={null}
{
  "error": {
    "status": "INVALID_ARGUMENT",
    "message": "ownerEmail is required."
  }
}
```

<ResponseExample>
  ```js theme={null}
  {
    "result": {
      "status": "success",
      "message": "API key created successfully.",
      "data": {
        "apiKey": "your_new_api_key"
      }
    }
  }
  ```
</ResponseExample>
