Create certificate

Create an SSL certificate for your site.


POST/api/servers/{server}/sites/{site}/certificates

Create certificate

This endpoint allows you to create an SSL certificate for your site.

Required parameters

  • Name
    type
    Type
    string
    Description

    The certificate type. Options: letsencrypt, custom.

  • Name
    certificate
    Type
    string
    Description

    For Let's Encrypt: the domains to request SSL for, comma separated, example: domain.com,www.domain.com. For custom: the certificate contents.

Optional parameters

  • Name
    private
    Type
    string
    Description

    Required when type is custom. The private key for the certificate.

  • Name
    force
    Type
    boolean
    Description

    Skips the Ploi check that the domain points to your server's IP address.

  • Name
    additional[use_dns_provider]
    Type
    boolean
    Description

    Set to true to validate the certificate through a DNS provider instead of HTTP validation. Not needed for wildcard certificates, those always use DNS validation.

  • Name
    additional[provider]
    Type
    string
    Description

    The DNS provider to use for validation, required for wildcard certificates or when additional[use_dns_provider] is true. Possible values: cloudflare, digitalocean, linode, route53, hetzner or bunny.

  • Name
    additional[secret]
    Type
    string
    Description

    The API token for the DNS provider, required for DNS validation when additional[use_from_profile] is not set. For Cloudflare this is an API token with the Zone, DNS, Edit permission, not the Global API Key. For Route 53 this is the AWS secret access key.

  • Name
    additional[key]
    Type
    string
    Description

    Only used for Route 53: the AWS access key ID. The other providers only need additional[secret].

  • Name
    additional[use_from_profile]
    Type
    boolean
    Description

    Set to true to use a DNS provider credential stored on the server owner's profile instead of passing an API token.

  • Name
    additional[credential]
    Type
    integer
    Description

    The ID of the DNS provider credential from the server owner's profile, required when additional[use_from_profile] is true.

HTTP or DNS validation

By default Let's Encrypt validates the domain over HTTP, so it has to reach your server on port 80. Passing a DNS provider in additional is not enough to change that. Set additional[use_dns_provider] to true as well, otherwise the request still uses HTTP validation.

Use DNS validation when port 80 is closed, or when the domain sits behind a proxy such as Cloudflare. Wildcard certificates (*.domain.com) always use DNS validation, so they only need additional[provider] and additional[secret].

Request

POST
/api/servers/{server}/sites/{site}/certificates
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" \
  -d '{"certificate": "domain.com", "type": "letsencrypt"}'

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" \
  -d '{
    "type": "letsencrypt",
    "certificate": "domain.com,*.domain.com",
    "additional": {
      "provider": "cloudflare",
      "secret": "your-cloudflare-api-token"
    }
  }'

Response

{
  "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"
  }
}