--- title: "Create key" source_url: https://dev.digicert.com/certcentral-apis/services-api/api-keys/create-key.html api_method: POST api_endpoint: "/services/v2/key/user/{{user_id}}" api_url: "https://www.digicert.com/services/v2/key/user/{{user_id}}" --- **POST** `https://www.digicert.com/services/v2/key/user/{{user_id}}` Use this endpoint to create a new API key for a specific user. > **Warning** > > The API key is shown only this one time in the creation response. It will never be shown again and there is no way to retrieve it if lost. ## Example requests and responses **cURL** ```bash curl -X POST \ 'https://www.digicert.com/services/v2/key/user/{{user_id}}' \ -H 'Content-Type: application/json' \ -H 'X-DC-DEVKEY: {{api_key}}' \ -d '{ "name": "New API Key" }' ``` **Python** ```python import requests url = "https://www.digicert.com/services/v2/key/user/{{user_id}}" payload = "{\n \"name\": \"New API Key\"\n}" headers = { 'X-DC-DEVKEY': "{{api_key}}", 'Content-Type': "application/xml" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text) ``` **Go** ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://www.digicert.com/services/v2/key/user/{{user_id}}" payload := strings.NewReader("{\n \"name\": \"New API Key\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-DC-DEVKEY", "{{api_key}}") req.Header.Add("Content-Type", "application/xml") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` **NodeJS** ```javascript var request = require("request"); var options = { method: 'POST', url: 'https://www.digicert.com/services/v2/key/user/{{user_id}}', headers: { 'Content-Type': 'application/xml', 'X-DC-DEVKEY': '{{api_key}}' }, body: '{\n "name": "New API Key"\n}' }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` ## 201 Created ```json { "id": 184, "api_key": "Aqdgb0p5U153195f22s6pw5cj0mfvp06xg89xw0xhh3zhc2" } ``` ## Request parameters
| Name | Req/Opt | Type | Description |
|---|---|---|---|
| name | required | string | Name of the key. |
| restricted_to_role_id | optional | int | To limit API key permissions, specify the API key role ID. Allowed values: 0, 100, 101, 102, 103. For more information, see Glossary – API key roles. |
| Name | Type | Description |
|---|---|---|
| id | int | Unique identifier for the created key. |
| api_key | string | Randomly generated API key. |