Create certificate
Create a certificate in your site
POST api/servers/{server}/sites/{site}/certificates
Parameters
Parameter | Type | Status | Description |
---|---|---|---|
type | string | required | Possible values: letsencrypt , custom |
certificate | string | required | When type is 'letsencrypt' enter the domain you want to request SSL for, when type is custom enter the certificate contents |
private | string | required when type is custom |
When type is custom enter the private key for the certificate |
force | boolean | optional | Force the request, bypassing the validation from Ploi |
additional | object | optional | Required when you want additional data to SSL request, examples are listed below |
Example request for Let's Encrypt:
curl -X POST "https://ploi.io/api/servers/{server}/sites/{site}/certificates" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{"certificate":"domain.com", "type":"letsencrypt"}'
Example request for custom certificate:
curl -X POST "https://ploi.io/api/servers/{server}/sites/{site}/certificates" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{"type":"custom", "certificate":"...", "private": "..." }'
Example request for Let's Encrypt certificate with DNS validation:
curl -X POST "https://ploi.io/api/servers/{server}/sites/{site}/certificates" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{"type":"letsencrypt", "domain": "domain.com,*.domain.com", "additional": {"provider": "cloudflare", "use_dns_provider": true, "key": "KEY", "secret": "SECRET"}}'
Example request for Let's Encrypt wildcard certificate:
curl -X POST "https://ploi.io/api/servers/{server}/sites/{site}/certificates" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data '{"type":"letsencrypt", "domain": "domain.com,*.domain.com", "additional": {"provider": "cloudflare", "key": "KEY", "secret": "SECRET"}}'
Example response:
HTTP/1.1 201 CREATED
Content-Type: application/json
{
"data": {
"id": 1,
"status": "created",
"domain": "domain.com",
"type": "letsencrypt",
"site_id": 1,
"server_id": 1,
"expires_at": null,
"created_at": "2019-07-31 08:34:25"
}
}