---
title: "Create a key"
url: "https://docs.unified.to/compute/key/Create_a_key"
description: "Create a key with Unified's Key API (POST /compute/{connection_id}/key). Filter by fields and raw. Supported by 11 Key integrations."
---
# Create a key

 POST/compute/{connection\_id}/key

## Parameters

**fields**string array 

id

created\_at

updated\_at

name

type

public\_key

private\_key

fingerprint

registry\_url

username

secret

instance\_id

expires\_at

raw

Fields to return

**raw**string 

Raw parameters to include in the 3rd-party request. Encoded as a URL component. eg. raw parameters: foo=bar&zoo=bar -> raw=foo%3Dbar%26zoo%3Dbar

**connection\_id**string  required 

ID of the connection

## Payload

**id**string 

Unique identifier for the key

**created\_at**date-time 

When the key was created (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)

**updated\_at**date-time 

When the key was last updated (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)

**name**string 

Display name of the key

**type** enum

Valid values:

 "SSH" 

 "REGISTRY" 

 "SECRET" 

 "OTHER" 

The kind of credential

**public\_key**string 

SSH public key

**private\_key**string 

SSH private key generated by the vendor; returned only in the create response

**fingerprint**string 

SSH key fingerprint

**registry\_url**string 

Container registry URL (REGISTRY keys)

**username**string 

Registry or SSH username

**secret**string 

Registry password or secret value (write-only; never returned)

**instance\_id**string 

The instance this key is scoped to, for per-instance keys

**expires\_at**date-time 

When the key expires (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)

**raw** 

Raw data from integration

## Returns

[ComputeKey](https://docs.unified.to/compute/key/model.md)

| Response field | Type               | Required | Description                                                                   |
| -------------- | ------------------ | -------- | ----------------------------------------------------------------------------- |
| id             | string             | No       | Unique identifier for the key                                                 |
| created\_at    | string (date-time) | No       | When the key was created (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)             |
| updated\_at    | string (date-time) | No       | When the key was last updated (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)        |
| name           | string             | No       | Display name of the key                                                       |
| type           | enum               | No       | The kind of credential Values: SSH, REGISTRY, SECRET, OTHER                   |
| public\_key    | string             | No       | SSH public key                                                                |
| private\_key   | string             | No       | SSH private key generated by the vendor; returned only in the create response |
| fingerprint    | string             | No       | SSH key fingerprint                                                           |
| registry\_url  | string             | No       | Container registry URL (REGISTRY keys)                                        |
| username       | string             | No       | Registry or SSH username                                                      |
| secret         | string             | No       | Registry password or secret value (write-only; never returned)                |
| instance\_id   | string             | No       | The instance this key is scoped to, for per-instance keys                     |
| expires\_at    | string (date-time) | No       | When the key expires (ISO-8601 / YYYY-MM-DDTHH:MM:SSZ format)                 |

## Errors

 Errors return the HTTP status code and a JSON body with `statusCode`, `error` (the short label) and `message` (a human-readable detail). 

```json
{
  "statusCode": 429,
  "error": "Too Many Requests",
  "message": "Too many requests to unified.to API; max requests per minute: N"
}
```

| Status | Error                 | Meaning                                           |
| ------ | --------------------- | ------------------------------------------------- |
| 400    | Bad Request           | The request was malformed or failed validation.   |
| 401    | Unauthorized          | The connection is likely broken; re-authorize it. |
| 403    | Forbidden             | The connection is missing permissions or scopes.  |
| 404    | Not Found             | The requested resource does not exist.            |
| 429    | Too Many Requests     | Rate limit exceeded (see the two sources below).  |
| 500    | Internal Server Error | An unexpected error occurred.                     |
| 501    | Not Implemented       | Not supported by this integration.                |

 Errors from the underlying integration pass through: the integration's status comes back as ours (429, 401, 403, 404 or 5xx), usually with its message. When the integration's error body is unclear, Unified extracts what it can and returns a clearer message. 

### 429 Too Many Requests

A 429 has two possible sources:

* The integration's own rate limit, passed through.
* Unified's workspace limit: a rolling 60 seconds, set by plan, with the message `Too many requests to unified.to API; max requests per minute: N`.

## Code Samples

### Node.js SDK

```javascript
import { UnifiedTo } from '@unified-api/typescript-sdk';

const sdk = new UnifiedTo({
    security: {
        jwt: '<YOUR_API_KEY_HERE>',
    },
});

const connectionId = '5de520f96e439b002043d8dc';

const results = await sdk.compute.createComputeKey({ connectionId, computeKey: { }, 
    fields: '',
    raw: '',
 });
```

### Node.js (axios)

```javascript
const options = {
  method: 'POST',
  url: 'https://api.unified.to/compute/5de520f96e439b002043d8dc/key',
  headers: {
    authorization: 'bearer .....'
  },
  data: undefined,
  params: {
    fields: '',
    raw: '',
  }
};

const results = await axios.request(options);
```

### Java

```java
AsyncHttpClient client = new DefaultAsyncHttpClient();

client.prepare("POST", "https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw=")
  .setHeader("accept", "application/json")
  .setHeader("authorization", ".....")
  .execute()
  .toCompletableFuture()
  .thenAccept(System.out::println)
  .join();

client.close();
```

### Go

```go
import (
	"fmt"
	"net/http"
	"io/ioutil"
)

url := `https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw=

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("accept", "application/json")
req.Header.Add("authorization", ".....")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
```

### Python

```python
import requests

url = "https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw="

headers = {
    "accept": "application/json",
    "authorization": "....."
}

response = requests.post(url, headers=headers)
```

### PHP

```php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw=",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "authorization: ....."
  ],
]);
```

### Ruby

```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw=")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["authorization"] = '....'

response = http.request(request)
puts response.read_body
```

### cURL

```bash
curl --request POST \
  --url 'https://api.unified.to/compute/5de520f96e439b002043d8dc/key?fields=&raw=' \
  --header 'accept: application/json' \
  --header 'authorization: .....'
```
