Certificates

Create a Certificate

Creates a new Certificate.

The default type uploaded allows for uploading your existing certificate and private_key in PEM format. You have to monitor its expiration date and handle renewal yourself.

In contrast, type managed requests a new Certificate from Let's Encrypt for the specified domain_names. Only domains managed by Hetzner DNS are supported. We handle renewal and timely alert the project owner via email if problems occur.

For type managed Certificates the action key of the response contains the Action that allows for tracking the issuance process. For type uploaded Certificates the action is always null.

post/certificates

Request

  • Base URL: https://api.hetzner.cloud/v1
  • URL: https://api.hetzner.cloud/v1/certificates
  • Auth: HTTP bearer

Request body

namestring required

Name of the Certificate.

labelsobject

User-defined labels (key/value pairs) for the Resource. For more information, see "Labels".

type'uploaded' | 'managed'

Choose between uploading a Certificate in PEM format or requesting a managed Let's Encrypt Certificate.

certificatestring

Certificate and chain in PEM format, in order so that each record directly certifies the one preceding. Required for type uploaded Certificates.

private_keystring

Certificate key in PEM format. Required for type uploaded Certificates.

domain_namesstring[]

Domains and subdomains that should be contained in the Certificate issued by Let's Encrypt. Required for type managed Certificates.

Example request

{
  "name": "my website cert",
  "labels": {
    "environment": "prod",
    "example.com/my": "label",
    "just-a-key": ""
  },
  "type": "uploaded",
  "certificate": "-----BEGIN CERTIFICATE-----\n...",
  "private_key": "-----BEGIN PRIVATE KEY-----\n...",
  "domain_names": [
    "example.com",
    "www.example.com"
  ]
}

Response

Request succeeded.

Example response

{
  "certificate": {
    "id": 42,
    "name": "my-resource",
    "labels": {
      "environment": "prod",
      "example.com/my": "label",
      "just-a-key": ""
    },
    "type": "uploaded",
    "certificate": "-----BEGIN CERTIFICATE-----\n...",
    "created": "2016-01-30T23:55:00Z",
    "not_valid_before": "2019-01-08T10:00:00Z",
    "not_valid_after": "2019-07-08T09:59:59Z",
    "domain_names": [
      "example.com",
      "webmail.example.com",
      "www.example.com"
    ],
    "fingerprint": "03:c7:55:9b:2a:d1:04:17:09:f6:d0:7f:18:34:63:d4:3e:5f",
    "status": {
      "issuance": "completed",
      "renewal": "scheduled"
    },
    "used_by": [
      {
        "id": 4711,
        "type": "load_balancer"
      }
    ]
  },
  "action": {
    "id": 42,
    "command": "start_resource",
    "started": "2016-01-30T23:55:00Z",
    "finished": "2016-01-30T23:55:00Z",
    "progress": 100,
    "resources": [
      {
        "id": 42,
        "type": "server"
      }
    ],
    "error": {
      "code": "action_failed",
      "message": "Action failed"
    }
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.