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

# createApiKey

> Creates a tenant-level API key for the API `apiId`, with the given scopes. Returns the key with its secret, the only time you can read it.



**mutation** `createApiKey(input: CreateApiKeyInput!): CreateApiKeyPayload!`

## Arguments

**`input`**: `CreateApiKeyInput!` (required)

## Returns

`CreateApiKeyPayload!`

**`apiKeyWithSecret`**: `ApiKeyWithSecret`

---

**`errors`**: `[CreateApiKeyError!]`

## Examples

```graphql Mutation
mutation CreateApiKey($input: CreateApiKeyInput!) {
  createApiKey(input: $input) {
    apiKeyWithSecret {
      id
      key
    }
    errors {
      __typename
      ... on GraphQlError {
        code
        details {
          __typename
        }
        message
      }
    }
  }
}
```

```json Variables
{
  "input": {
    "apiId": "string",
    "name": "string",
    "scopeIds": [
      "string"
    ]
  }
}
```

```json Response
{
  "data": {
    "createApiKey": {
      "apiKeyWithSecret": {
        "id": "string",
        "key": "string"
      },
      "errors": [
        {
          "__typename": "GraphQlError",
          "code": "string",
          "details": [
            {
              "__typename": "KeyValuePairOfStringAndString"
            }
          ],
          "message": "string"
        }
      ]
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.