# Create an API Key This creates an API Key, which will return the API Key components in the response. The Key ID will be found at and the Key Secret will be found at . For security reasons the Key Secret will only be available during creation so make sure to save it. To use a newly-created Ingest Key it should be passed in the header with the API Key's ID and secret concatenated (and with no separator). For example, Check out our best practices for API Keys. Endpoint: POST /2/teams/{teamSlug}/api-keys Version: 1.0.0 Security: bearerAuth ## Path parameters: - `teamSlug` (string, required) The slug of the Team ## Request fields (application/vnd.api+json): - `data` (object, required) Example: {"type":"api-keys","attributes":{"name":"my ingest key","key_type":"ingest","permissions":{"create_datasets":true}},"relationships":{"environment":{"data":{"id":"hcxen_12345678901234567890123456","type":"environments"}}}} - `data.type` (string, required) Enum: "api-keys" - `data.attributes` (object, required) Example: {"name":"my ingest key","key_type":"ingest","permissions":{"create_datasets":true}} - `data.attributes.key_type` (string, required) The type of API Key Enum: "ingest" - `data.attributes.name` (string, required) A human-readable name for the API Key Example: "my ingest key" - `data.attributes.disabled` (boolean) Whether the API Key is disabled - `data.attributes.permissions` (object) The permissions granted to this API Key Example: {"create_datasets":true} - `data.attributes.permissions.create_datasets` (boolean) Whether this API Key can create new Datasets Example: true - `data.relationships` (object, required) Example: {"environment":{"data":{"id":"hcxen_12345678901234567890123456","type":"environments"}}} - `data.relationships.environment` (object, required) The Environment this object is associated with. Example: {"data":{"id":"hcxen_12345678901234567890123456","type":"environments"}} ## Response 201 fields (application/vnd.api+json): - `data` (object, required) - `data.id` (string, required) The unique identifier of the API Key Example: "hcxik_12345678901234567890123456" - `data.type` (string, required) Enum: "api-keys" - `data.attributes` (object, required) - `data.attributes.key_type` (string, required) The type of API Key Enum: "ingest" - `data.attributes.name` (string, required) A human-readable name for the API Key Example: "us-west-2 collectors key" - `data.attributes.disabled` (boolean) Whether the API Key is disabled - `data.attributes.permissions` (object) The permissions granted to this API Key - `data.attributes.permissions.create_datasets` (boolean) Whether this API Key can create new Datasets - `data.attributes.timestamps` (object) - `data.attributes.timestamps.created` (string) The ISO8601-formatted time when the API Key was created. Example: "2022-09-22T17:32:11Z" - `data.attributes.timestamps.updated` (string) The ISO8601-formatted time when the API Key was updated. Example: "2022-10-31T15:08:11Z" - `data.attributes.secret` (string) The API Key secret. This is the only time it will be returned. Example: "12345678901234567890123456789" - `data.relationships` (object, required) - `data.relationships.environment` (object, required) The Environment this object is associated with. - `data.relationships.creator` (object, required) The User who initially created this resource. - `data.relationships.editor` (object, required) The User who last edited this resource. - `data.links` (object, required) - `data.links.self` (string) The URL of this resource Example: "/2/teams/my-team/api-keys/hcxik_12345678901234567890123456" ## Response 400 fields (application/problem+json): - `error` (string, required) - `status` (number, required) The HTTP status code of the error. - `type` (string, required) Type is a URI used to uniquely identify the type of error. - `title` (string, required) Title is a human-readable summary that explains the of the problem. - `detail` (string) The general, human-readable error message. - `instance` (string) The unique identifier (ID) for this specific error. ## Response 401 fields (application/json): - `error` (string) ## Response 403 fields (application/json): - `error` (string) ## Response 404 fields (application/json): - `error` (string) ## Response 413 fields (application/json): - `error` (string, required) - `status` (number, required) The HTTP status code of the error. - `type` (string, required) Type is a URI used to uniquely identify the type of error. - `title` (string, required) Title is a human-readable summary that explains the of the problem. - `detail` (string) The general, human-readable error message. - `instance` (string) The unique identifier (ID) for this specific error. ## Response 415 fields (application/vnd.api+json): - `errors` (array) - `errors.id` (string, required) - `errors.status` (string) - `errors.code` (string, required) - `errors.title` (string) - `errors.detail` (string) - `errors.source` (object) - `errors.source.pointer` (string) - `errors.source.header` (string) - `errors.source.parameter` (string) ## Response 422 fields (application/problem+json): - `error` (string, required) - `status` (number, required) The HTTP status code of the error. - `type` (string, required) Type is a URI used to uniquely identify the type of error. - `title` (string, required) Title is a human-readable summary that explains the of the problem. - `detail` (string) The general, human-readable error message. - `instance` (string) The unique identifier (ID) for this specific error. - `type_detail` (array) - `type_detail.field` (string) - `type_detail.code` (string) Enum: "invalid", "missing", "incorrect_type", "already_exists" - `type_detail.description` (string) ## Response 429 fields (application/json): - `error` (string) ## Response 500 fields (application/problem+json): - `error` (string, required) - `status` (number, required) The HTTP status code of the error. - `type` (string, required) Type is a URI used to uniquely identify the type of error. - `title` (string, required) Title is a human-readable summary that explains the of the problem. - `detail` (string) The general, human-readable error message. - `instance` (string) The unique identifier (ID) for this specific error.