The ssh-key
object represents an SSH key which includes a name and the SSH private key. An organization can have multiple SSH keys available.
SSH keys can be used in two places:
oauth-tokens
. Refer to OAuth Tokens for additional information. Azure DevOps Server and Bitbucket Data Center require an SSH key. Other providers only require an SSH key when your repositories include submodules that are only accessible using an SSH connection instead of your VCS provider's API.Listing and viewing SSH keys requires either permission to manage VCS settings for the organization, or admin access to at least one workspace. (More about permissions.)
Important: The list and read methods on this API only provide metadata about SSH keys. The actual private key text is write-only, and HCP Terraform never provides it to users via the API or UI.
GET /organizations/:organization_name/ssh-keys
:organization_name
The name of the organization to list SSH keys for.
Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.
Query ParametersThis endpoint supports pagination with standard URL query parameters. Remember to percent-encode [
as %5B
and ]
as %5D
if your tooling doesn't automatically encode URLs. If neither pagination query parameters are provided, the endpoint will not be paginated and will return all results.
page[number]
Optional. If omitted, the endpoint will return the first page. page[size]
Optional. If omitted, the endpoint will return 20 ssh keys per page. Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
https://app.terraform.io/api/v2/organizations/my-organization/ssh-keys
Sample Response
{
"data": [
{
"attributes": {
"name": "SSH Key"
},
"id": "sshkey-GxrePWre1Ezug7aM",
"links": {
"self": "/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM"
},
"type": "ssh-keys"
}
]
}
GET /ssh-keys/:ssh_key_id
:ssh_key_id
The SSH key ID to get.
This endpoint is for looking up the name associated with an SSH key ID. It does not retrieve the key text.
Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.
Sample Requestcurl \
--header "Authorization: Bearer $TOKEN" \
https://app.terraform.io/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM
Sample Response
{
"data": {
"attributes": {
"name": "SSH Key"
},
"id": "sshkey-GxrePWre1Ezug7aM",
"links": {
"self": "/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM"
},
"type": "ssh-keys"
}
}
POST /organizations/:organization_name/ssh-keys
:organization_name
The name of the organization to create an SSH key in. The organization must already exist, and the token authenticating the API request must have permission to manage VCS settings. (More about permissions.)
Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.
Request BodyThis POST endpoint requires a JSON object with the following properties as a request payload.
Properties without a default value are required.
Key path Type Default Descriptiondata.type
string Must be "ssh-keys"
. data.attributes.name
string A name to identify the SSH key. data.attributes.value
string The text of the SSH private key. Sample Payload
{
"data": {
"type": "ssh-keys",
"attributes": {
"name": "SSH Key",
"value": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAm6+JVgl..."
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/v2/organizations/my-organization/ssh-keys
Sample Response
{
"data": {
"attributes": {
"name": "SSH Key"
},
"id": "sshkey-GxrePWre1Ezug7aM",
"links": {
"self": "/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM"
},
"type": "ssh-keys"
}
}
PATCH /ssh-keys/:ssh_key_id
:ssh_key_id
The SSH key ID to update.
This endpoint replaces the name of an existing SSH key.
Editing SSH keys requires permission to manage VCS settings. (More about permissions.)
Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.
Request BodyThis POST endpoint requires a JSON object with the following properties as a request payload.
Properties without a default value are required.
Key path Type Default Descriptiondata.type
string Must be "ssh-keys"
. data.attributes.name
string (nothing) A name to identify the SSH key. If omitted, the existing name is preserved. Sample Payload
{
"data": {
"attributes": {
"name": "SSH Key for GitHub"
}
}
}
Sample Request
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request PATCH \
--data @payload.json \
https://app.terraform.io/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM
Sample Response
{
"data": {
"attributes": {
"name": "SSH Key for GitHub"
},
"id": "sshkey-GxrePWre1Ezug7aM",
"links": {
"self": "/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM"
},
"type": "ssh-keys"
}
}
DELETE /ssh-keys/:ssh_key_id
:ssh_key_id
The SSH key ID to delete.
Deleting SSH keys requires permission to manage VCS settings. (More about permissions.)
Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.
Sample Requestcurl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request DELETE \
https://app.terraform.io/api/v2/ssh-keys/sshkey-GxrePWre1Ezug7aM
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4