Encryption
Certificates
Upload your own edge certificates, issue origin certificates and read every certificate of a domain.
A domain has two kinds of certificate. Edge certificates are the ones visitors see: the universal certificate, and the custom ones you upload. Origin certificates are issued by the CDN for your origin server. The paths start with /v2/cdn/certificates/{domain_public_id}/, where the id is the public id of the domain, taken from the domains list.
The examples on this page use these shell variables:
export DIAMWALL_API_KEY="your key"export CERTS="https://api.diamwall.com/v2/cdn/certificates/your-domain-public-id"How the answers read
Section titled “How the answers read”No read returns a key or a PEM
Section titled “No read returns a key or a PEM”A read answers the public metadata of a certificate, under certificate.value: subject, issuer, hostnames, not_before, not_after, fingerprint_sha256 and status. The status is active, expired or not_yet_valid.
The private key of a custom certificate you upload is never answered back. The private key of an origin certificate is answered once, by the call that creates it.
Unknown is not empty
Section titled “Unknown is not empty”Most values come with a state. Only resolved carries a value you can show.
| What you see | What it means |
|---|---|
state: "resolved" with a value |
The value was read. |
state: "resolved" with items: [] or value: [] |
The domain has no certificate of that kind. |
state: "unknown" |
The value is unavailable. A reason may say why. |
state: "unrecognized" |
A state this API does not know. Treat it as unavailable. |
Show unknown as unavailable. It never means that the domain has no certificate, and never that a certificate is healthy.
Writes need the latest revision
Section titled “Writes need the latest revision”Each of the two collections has a revision. A read of a collection, or of one certificate in it, answers that revision in the ETag header. Every create and delete sends it back in If-Match, exactly as it came, with its quotes.
- Without
If-Matchthe write answers428 PRECONDITION_REQUIRED. - If the collection changed since your read, it answers
412 REVISION_MISMATCH. Read again and retry. - A weak ETag,
*, a list or a value without quotes answers400 INVALID_PRECONDITION. - Every write answers a new
ETagto use on the next one.
The edge collection and the origin collection have separate revisions. Use the ETag of the one you write to.
Overview of a domain
Section titled “Overview of a domain”One read answers the universal certificate, the custom edge certificates and the origin certificates together. It costs 8 credits, where a read of either collection costs 60, so use it to draw a page of certificates.
curl "$CERTS/settings/certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"{ "revision": "sha256:f315781722ba...", "consistency": "verified", "data": { "certificate_verification_enabled": false, "edge": { "universal": { "state": "resolved", "value": { "certificate": { "state": "resolved", "value": { "subject": "CN=example.com", "hostnames": ["example.com", "www.example.com"], "not_after": "2027-10-10T00:00:00.000Z", "status": "active" } } } }, "custom": { "state": "resolved", "value": [] } }, "origin": { "state": "resolved", "value": [] } }}| Field | What it holds |
|---|---|
data.edge.universal |
The universal certificate. A value of null under resolved means the domain has none. |
data.edge.custom |
The custom edge certificates, as their collection lists them. |
data.origin |
The origin certificates, the deleted ones included. |
data.certificate_verification_enabled |
Whether verification of the origin’s TLS certificate is enabled. When the field is absent the value is unavailable, not false. |
- This endpoint is read-only and answers no
ETag. Certificates are created and deleted through the two collections below. - When the whole group is unavailable, the answer is still
200, with a top-levelstateofunknown, arevisionofnulland nodata. certificate_verification_enabledonly says the setting is on. It does not say that a check of the origin’s certificate passed.
Edge certificates
Section titled “Edge certificates”The edge collection holds the custom certificates you uploaded and, when the domain has one, the universal certificate. The universal certificate has the id universal. You can read it, but not delete it.
List the edge certificates
Section titled “List the edge certificates”curl "$CERTS/edge-certificates/?limit=50" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"{ "revision": "sha256:118dfdf1af1e...", "consistency": "verified", "data": { "state": "resolved", "items": [ { "id": "0123456789abcdef", "type": "custom", "primary_hostname": "example.com", "hostnames": ["example.com", "www.example.com"], "uploaded_at": "2026-10-10T00:00:00.000Z", "key_status": { "state": "resolved", "value": { "algorithm": "ec", "matches_certificate": true, "present": true } }, "certificate": { "state": "resolved", "value": { "subject": "CN=example.com", "issuer": "CN=Example Issuing CA", "hostnames": ["example.com", "www.example.com"], "not_before": "2026-10-10T00:00:00.000Z", "not_after": "2027-10-10T00:00:00.000Z", "status": "active" } } } ], "page": { "limit": 50, "next_cursor": null, "total": 1 } }}limitgoes from 1 to 100. Without it a page holds 50 certificates. No other query parameter is accepted besideslimitandcursor.- To read the next page, send
data.page.next_cursorback ascursor, until it isnull. - If the collection changes between two pages, the next page answers
409 CURSOR_STALE. Start again from the first page. - Check
data.statefirst. When it is notresolved, the answer is still200, but it has noitems, nopageand noETag: the certificates are unavailable. - The universal item has
type: "universal"and no hostnames or upload date of its own. If itscertificate.stateisunknown, show it as unavailable.
Upload a custom certificate
Section titled “Upload a custom certificate”Read the collection first to get the ETag:
ETAG=$(curl -s -o /dev/null -D - "$CERTS/edge-certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')Then send the certificate and its private key, each as a PEM string. jq builds the JSON body from the two files:
jq -n --rawfile cert fullchain.pem --rawfile key privkey.pem \ '{ certificate: $cert, private_key: $key, hostnames: ["example.com", "www.example.com"] }' \ | curl -X POST "$CERTS/edge-certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ETAG" \ -d @-| Field | Required | Rules |
|---|---|---|
certificate |
Yes | A PEM string, not empty, at most 1 MiB. |
private_key |
Yes | A PEM string, not empty, at most 1 MiB. |
hostnames |
No | 1 to 100 hostnames of 1 to 253 characters, each once. Each has to belong to the domain and be covered by the certificate. Without it, the hostnames are taken from the certificate. |
The whole body holds at most 3 MiB. Any other field is refused.
The answer is 201 with the new certificate under data, its id in operation.id, and a new ETag header. Neither the certificate nor the key you sent is answered back.
The certificate has to match its key, be valid now and for at least 14 more days, and cover hostnames of the domain. Otherwise the upload is refused and nothing is written. See the error table for the codes.
Read one edge certificate
Section titled “Read one edge certificate”The id is the id from the list: 16 lowercase hexadecimal digits for a custom certificate, or universal.
curl "$CERTS/edge-certificates/0123456789abcdef/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"The ETag header of the answer is the revision of the whole collection, so you can use it in If-Match for a delete. An id in the wrong form answers 400 INVALID_REQUEST. An id that no certificate has answers 404 RESOURCE_ITEM_NOT_FOUND.
Delete a custom certificate
Section titled “Delete a custom certificate”curl -X DELETE "$CERTS/edge-certificates/0123456789abcdef/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "If-Match: $ETAG"The answer has no data. operation.id is the id the certificate had, and the ETag header is the new revision of the collection.
The universal certificate cannot be deleted: the id universal answers 400 INVALID_REQUEST. After 502 FILE_SERVER_OUTCOME_UNKNOWN or 503 READBACK_MISMATCH the certificate may have been deleted, so read the collection before you try again.
Origin certificates
Section titled “Origin certificates”An origin certificate is issued by the CDN for the origin of the domain. The CDN generates the key and the certificate, and answers both once. You install them on your origin server.
List the origin certificates
Section titled “List the origin certificates”curl "$CERTS/origin-certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"Each item has its id, hostnames, key_type, created_at, revoked, revoked_at and the public metadata under certificate. Paging, data.state and the ETag work the same way as for the edge list.
A deleted certificate stays in the list, with revoked: true, a revoked_at date and a certificate with no value.
Create an origin certificate
Section titled “Create an origin certificate”Read the origin collection to get its ETag, then send the create. Every field of the body is optional, but the body itself is required: send {} to take the defaults.
ORIGIN_ETAG=$(curl -s -o /dev/null -D - "$CERTS/origin-certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')
curl -X POST "$CERTS/origin-certificates/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ORIGIN_ETAG" \ -o origin-certificate.json \ -d '{ "hostnames": ["example.com", "*.example.com"], "validity_years": 5, "key_type": "rsa" }'| Field | Allowed values | Without it |
|---|---|---|
hostnames |
A list of hostnames of the domain, 1 to 253 characters each | The domain and its wildcard |
validity_years |
1, 2, 3, 5, 10 or 15, as a number |
15 |
key_type |
ecdsa or rsa |
ecdsa |
The answer is 201. The certificate’s metadata is under data, and the material is under operation.result:
{ "data": { "id": "76543210fedcba98", "key_type": "ecdsa", "revoked": false }, "operation": { "type": "create", "id": "76543210fedcba98", "result": { "not_before": "2026-10-10T00:00:00.000Z", "not_after": "2041-10-10T00:00:00.000Z", "delivery": "one_time", "certificate": "-----BEGIN CERTIFICATE-----...", "ca_certificate": "-----BEGIN CERTIFICATE-----...", "private_key": "-----BEGIN PRIVATE KEY-----..." } }}A certificate whose key you do not have cannot be used. That happens when:
- the
201has nooperation.result, or noprivate_keyin it; - the answer was lost:
502 FILE_SERVER_OUTCOME_UNKNOWN, or503withREADBACK_MISMATCH,GENERATION_FAILEDorISSUANCE_VERIFICATION_FAILED.
In both cases, read the collection first. If it lists a certificate this request created, delete it, and only then create another. Do not repeat the request blindly: every certificate that was created stays in the history of the domain, and that history has a ceiling.
Read one origin certificate
Section titled “Read one origin certificate”curl "$CERTS/origin-certificates/76543210fedcba98/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"The id is 16 lowercase hexadecimal digits. The answer never holds the private key. If you lost the key, delete the certificate and create another. The ETag header is the revision of the whole origin collection.
Delete an origin certificate
Section titled “Delete an origin certificate”curl -X DELETE "$CERTS/origin-certificates/76543210fedcba98/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "If-Match: $ORIGIN_ETAG"The answer has no data. Read the collection to see the entry as it is now.
Limits and permissions
Section titled “Limits and permissions”- Plan. Every endpoint on this page needs the Business or Enterprise plan. On any other plan the call answers
403 FEATURE_NOT_AVAILABLE, withdetails.feature(custom_certificatesororigin_certificates) anddetails.plan, and spends no credits. - Custom certificate limit. A Business domain has 1 custom certificate. An Enterprise domain has no limit. The universal certificate does not count. An upload at the limit answers
400 PLAN_LIMIT_EXCEEDED, withdetails.limitanddetails.plan. - Credits. Each domain has a budget of 3000 credits a minute, shared by everyone who calls the API for that domain.
- Out of credits. The call answers
429 TOO_MANY_REQUESTS, with the wait indetails.retry_after_seconds. - Refused early. A request refused before it reaches the CDN (a
400for its body, id orIf-Match, a403, a413or a428) spends no credits.
| Call | Cost |
|---|---|
GET .../settings/certificates/ |
8 credits |
| A read of either collection | 60 credits |
| Upload a custom certificate, on a plan with no limit | 60 credits |
| Upload a custom certificate, on a plan with a limit | 120 credits |
| Create an origin certificate | 60 credits |
| Delete an edge or origin certificate | 60 credits |
| Action | Permission on the domain |
|---|---|
| Any read | ssl.view |
| Upload a custom certificate, create an origin certificate | ssl.create |
| Delete a custom certificate | ssl.delete |
| Delete an origin certificate | ssl.edit. Whoever holds ssl.create or ssl.delete holds it too. |
Errors you are likely to see
Section titled “Errors you are likely to see”| Status | Code | What happened |
|---|---|---|
400 |
INVALID_REQUEST |
A field, a query parameter or the certificate id is wrong. The answer names it in fields when it can. An origin create with no body answers this too. |
400 |
INVALID_PRECONDITION |
The If-Match is not one quoted strong ETag. |
400 |
PLAN_LIMIT_EXCEEDED |
The domain is at the custom certificate limit of its plan. |
400 |
INVALID_CERTIFICATE |
The certificate you uploaded was refused as invalid. |
400 |
PRIVATE_KEY_MISMATCH |
The private key does not match the certificate. |
400 |
CERTIFICATE_EXPIRED, CERTIFICATE_EXPIRING, CERTIFICATE_NOT_YET_VALID |
The certificate is not valid now and for 14 more days. |
400 |
CERTIFICATE_HOSTNAME_MISMATCH |
The certificate does not cover the hostnames. |
400 |
INVALID_HOSTNAMES, HOSTNAMES_UNAVAILABLE |
The hostnames were refused. |
400 |
INVALID_KEY_TYPE, INVALID_VALIDITY |
The key_type or validity_years of an origin certificate was refused. |
403 |
FEATURE_NOT_AVAILABLE |
The domain’s plan does not include certificates. |
404 |
RESOURCE_ITEM_NOT_FOUND |
No certificate has that id. |
409 |
CURSOR_STALE |
The collection changed while you were paging. Start from the first page. |
409 |
HOSTNAME_CONFLICT |
The upload was refused over its hostnames. Nothing was written. |
409 |
QUOTA_EXCEEDED |
The CDN’s own ceiling of certificates was reached. This is not the plan limit. |
409 |
ARTIFACT_CONFLICT |
The create was refused for the state of the domain’s certificates. Nothing was written. |
412 |
REVISION_MISMATCH |
The collection changed since your read. Read again and retry. |
413 |
PAYLOAD_TOO_LARGE |
The body is larger than 3 MiB. |
428 |
PRECONDITION_REQUIRED |
The If-Match header is missing. |
429 |
TOO_MANY_REQUESTS |
The domain is out of credits for now. |
502 |
FILE_SERVER_OUTCOME_UNKNOWN |
The write may have been made. Read the collection before anything else. |
503 |
READBACK_MISMATCH |
The outcome of the write is unconfirmed. Read the collection before anything else. |
503 |
GENERATION_FAILED, ISSUANCE_VERIFICATION_FAILED |
An origin create failed part way. The outcome is unconfirmed. Read the collection. |
503 |
ORIGIN_CA_UNAVAILABLE |
The origin certificate could not be issued right now. Nothing was created. |
The errors that come from the key itself, such as API_KEY_IP_NOT_ALLOWED, are on the Errors page.
All Certificates endpoints
Section titled “All Certificates endpoints”Each row opens the endpoint in the API reference, with every parameter, rule and response.
Loading the endpoints...