> ## Documentation Index
> Fetch the complete documentation index at: https://docs.velt.dev/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-auth-token` (from the Create Workspace response) as headers.
</Info>

# 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-auth-token" type="string" required>
  Your [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. Accepted values: `"testing"` or `"production"`. Production keys require `planInfo` or `customPlanInfo`.
    </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="planInfo" type="object">
      Plan information object associated with this API key. Required for `"production"` type unless `customPlanInfo` is `true`.

      <Expandable title="properties">
        <ParamField body="type" type="string">
          Plan type identifier (e.g., `"sdk test"`, `"production"`).
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="customPlanInfo" type="boolean">
      Whether to use custom plan info instead of standard `planInfo`.
    </ParamField>

    <ParamField body="customPlanInfoData" type="object">
      Freeform custom plan info data payload. Required when `customPlanInfo` is `true`. You can pass any key-value pairs needed for your custom plan configuration.
    </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>
