Add a new SSH key
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.wpengineapi.com/v1/ssh_keys"
payload := strings.NewReader("{ \"public_key\": \"ssh-rsa AAAAbcdefg+567te/4i9ASKGHtw9euaskl+Iksldfjw== joe@gmail.com\" }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <credentials>") req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}const url = 'https://api.wpengineapi.com/v1/ssh_keys';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"public_key":"ssh-rsa AAAAbcdefg+567te/4i9ASKGHtw9euaskl+Iksldfjw== joe@gmail.com"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.wpengineapi.com/v1/ssh_keys \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "public_key": "ssh-rsa AAAAbcdefg+567te/4i9ASKGHtw9euaskl+Iksldfjw== joe@gmail.com" }'Description
Use this to add a new SSH key to WP Engine.
Authorizations
Section titled “Authorizations ”Request Body
Section titled “Request Body ”Properties
- public_key - required - The public key you want to add
object
Example
ssh-rsa AAAAbcdefg+567te/4i9ASKGHtw9euaskl+Iksldfjw== joe@gmail.comResponses
Section titled “ Responses ”Created
object
Example
{ "comment": "joe@gmail.com", "created_at": "2019-09-01T15:59:24.277Z", "fingerprint": "a1:b2:c3:d4:e5:46:a7:88:c9:40:d2:d7:9b:cd:42:05", "uuid": "e41fa98f-ea80-1f16-a7b7-d748bcc9e64d"}Bad Request
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
An array of error objects describing specific errors that arose when servicing the request
object
The name of the resource that was being processed when the error occurred
(Optional) The specific field associated with the error
(Optional) A type associated with the error. invalid_value, access_error, value_unavailable
(Optional) A machine code relating to the error that occurred with the field and resource
(Optional) A human-readable message relating to the error that occurred with the field and resource
Example
{ "message": "Invalid Site: Name cannot be empty.", "errors": [ { "resource": "Site", "field": "name", "type": "invalid_value", "code": "too_long", "message": "Name is too long (maximum is 40 characters)" } ]}Authentication Error
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "Bad Credentials"}Not authorized
object
A message regarding the error that occurred on the server
(Optional) A URL where documentation regarding this specific error can be found
Example
{ "message": "You don't have permission to perform that action"}Too many requests
Service unavailable