# Get key

Returns a session key to start an authentication process with SPID, CIE, or EIDAS.
The key must be passed to the [Login](/products/esp/enterprise-documentation/developer-documentation/integration-guide/login) endpoint.

Deprecated endpoint
The previous endpoint `/sslprotected/environment_name/getKey` is deprecated. Use the endpoint below instead.

For the full technical reference, see the [OpenAPI specification](/products/esp/openapi/get-key).

#### Endpoint


```
GET /api/secure/{environment_name}/getKey
```

#### Headers

| Name | Required | Description |
|  --- | --- | --- |
| `Esp-Api-Key` | Yes | API key for the environment. |


#### Path parameters

| Name | Type | Required | Description |
|  --- | --- | --- | --- |
| `environment_name` | string | Yes | The environment path provided by Namirial during the assessment phase (e.g. `myintegration`) |


#### Query parameters

| Name | Type | Required | Description |
|  --- | --- | --- | --- |
| `attributes` | string | Yes | Attribute set: `Base` or `Full` |
| `level` | string | No | Authentication level: `1`, `2`, or `3`. Defaults to `1` |
| `spidType` | string | No | SPID purpose value. Applies to SPID authentication only. Defaults to physical person |


The `spidType` parameter is only relevant for SPID authentication.

#### Request example


```
GET /api/secure/myintegration/getKey?attributes=Base&level=2
```

#### Response examples

**200 — Session key**


```
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
```

The response is a string (`authnKey`) to be passed to the [Login](/products/esp/enterprise-documentation/developer-documentation/integration-guide/login) endpoint.

#### Error codes

| HTTP Status | Error code | Error type | Solution |
|  --- | --- | --- | --- |
| `400` | — | Bad request | Check that all required parameters are present and valid |
| `401` | — | Unauthorized | The API key is missing. Include the `Esp-Api-Key` header |
| `403` | — | Forbidden | The API key is invalid |
| `404` | — | Not found | The `environment_name` does not exist |