---
title: Create SSL Configuration
---

[Skip to content](#%5Ftop) 

[API Reference](https://developers.cloudflare.com/api/typescript)

[Custom Certificates](https://developers.cloudflare.com/api/typescript/resources/custom%5Fcertificates)

Copy Markdown

Open in **Claude**

Open in **ChatGPT**

Open in **Cursor**

---

**Copy Markdown**

**View as Markdown**

# Create SSL Configuration

client.customCertificates.create(CustomCertificateCreateParams { zone\_id, certificate, bundle\_method, 6 more } params, RequestOptionsoptions?): [CustomCertificate](https://developers.cloudflare.com/api/typescript/resources/custom%5Fcertificates#%28resource%29%20custom%5Fcertificates%20%3E%20%28model%29%20custom%5Fcertificate%20%3E%20%28schema%29) { id, zone\_id, bundle\_method, 12 more } 

POST/zones/{zone\_id}/custom\_certificates

Upload a new SSL certificate for a zone.

##### Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).

**Example:**`Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY`

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**`X-Auth-Email: user@example.com`

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**`X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194`

##### Accepted Permissions (at least one required)

`Access: Mutual TLS Certificates Write` `SSL and Certificates Write`

##### ParametersExpand Collapse 

params: CustomCertificateCreateParams { zone\_id, certificate, bundle\_method, 6 more } 

zone\_id: string

Path param: Identifier.

maxLength32

certificate: string

Body param: The zone’s SSL certificate or certificate and the intermediate(s).

bundle\_method?: [BundleMethod](https://developers.cloudflare.com/api/typescript/resources/custom%5Fhostnames#%28resource%29%20custom%5Fhostnames%20%3E%20%28model%29%20bundle%5Fmethod%20%3E%20%28schema%29)

Body param: A ubiquitous bundle has the highest probability of being verified everywhere, even by clients using outdated or unusual trust stores. An optimal bundle uses the shortest chain and newest intermediates. And the force bundle verifies the chain, but does not otherwise modify it.

One of the following:

"ubiquitous"

"optimal"

"force"

custom\_csr\_id?: string

Body param: The identifier for the Custom CSR that was used.

deploy?: "staging" | "production"

Body param: The environment to deploy the certificate to, defaults to production.

One of the following:

"staging"

"production"

geo\_restrictions?: [GeoRestrictions](https://developers.cloudflare.com/api/typescript/resources/custom%5Fcertificates#%28resource%29%20custom%5Fcertificates%20%3E%20%28model%29%20geo%5Frestrictions%20%3E%20%28schema%29) { label } 

Body param: Specify the region where your private key can be held locally for optimal TLS performance. HTTPS connections to any excluded data center will still be fully encrypted, but will incur some latency while Keyless SSL is used to complete the handshake with the nearest allowed data center. Options allow distribution to only to U.S. data centers, only to E.U. data centers, or only to highest security data centers. Default distribution is to all Cloudflare datacenters, for optimal performance.

label?: "us" | "eu" | "highest\_security"

One of the following:

"us"

"eu"

"highest\_security"

policy?: string

Body param: Specify the policy that determines the region where your private key will be held locally. HTTPS connections to any excluded data center will still be fully encrypted, but will incur some latency while Keyless SSL is used to complete the handshake with the nearest allowed data center. Any combination of countries, specified by their two letter country code (<https://en.wikipedia.org/wiki/ISO%5F3166-1%5Falpha-2#Officially%5Fassigned%5Fcode%5Felements>) can be chosen, such as ‘country: IN’, as well as ‘region: EU’ which refers to the EU region. If there are too few data centers satisfying the policy, it will be rejected. Note: The API accepts this field as either “policy” or “policy\_restrictions” in requests. Responses return this field as “policy\_restrictions”.

private\_key?: string

Body param: The zone’s private key. Not required if custom\_csr\_id is provided, in which case the private key is retrieved from the CSR record held by Cloudflare.

type?: "legacy\_custom" | "sni\_custom"

Body param: The type ‘legacy\_custom’ enables support for legacy clients which do not include SNI in the TLS handshake.

One of the following:

"legacy\_custom"

"sni\_custom"

##### ReturnsExpand Collapse 

CustomCertificate { id, zone\_id, bundle\_method, 12 more } 

id: string

Identifier.

maxLength32

zone\_id: string

Identifier.

maxLength32

bundle\_method?: [BundleMethod](https://developers.cloudflare.com/api/typescript/resources/custom%5Fhostnames#%28resource%29%20custom%5Fhostnames%20%3E%20%28model%29%20bundle%5Fmethod%20%3E%20%28schema%29)

A ubiquitous bundle has the highest probability of being verified everywhere, even by clients using outdated or unusual trust stores. An optimal bundle uses the shortest chain and newest intermediates. And the force bundle verifies the chain, but does not otherwise modify it.

One of the following:

"ubiquitous"

"optimal"

"force"

custom\_csr\_id?: string

The identifier for the Custom CSR that was used.

expires\_on?: string

When the certificate from the authority expires.

formatdate-time

geo\_restrictions?: [GeoRestrictions](https://developers.cloudflare.com/api/typescript/resources/custom%5Fcertificates#%28resource%29%20custom%5Fcertificates%20%3E%20%28model%29%20geo%5Frestrictions%20%3E%20%28schema%29) { label } 

Specify the region where your private key can be held locally for optimal TLS performance. HTTPS connections to any excluded data center will still be fully encrypted, but will incur some latency while Keyless SSL is used to complete the handshake with the nearest allowed data center. Options allow distribution to only to U.S. data centers, only to E.U. data centers, or only to highest security data centers. Default distribution is to all Cloudflare datacenters, for optimal performance.

label?: "us" | "eu" | "highest\_security"

One of the following:

"us"

"eu"

"highest\_security"

hosts?: Array<string\>

issuer?: string

The certificate authority that issued the certificate.

keyless\_server?: [KeylessCertificate](https://developers.cloudflare.com/api/typescript/resources/keyless%5Fcertificates#%28resource%29%20keyless%5Fcertificates%20%3E%20%28model%29%20keyless%5Fcertificate%20%3E%20%28schema%29) { id, created\_on, enabled, 7 more } 

id: string

Keyless certificate identifier tag.

maxLength32

created\_on: string

When the Keyless SSL was created.

formatdate-time

enabled: boolean

Whether or not the Keyless SSL is on or off.

host: string

The keyless SSL name.

formathostname

maxLength253

modified\_on: string

When the Keyless SSL was last modified.

formatdate-time

name: string

The keyless SSL name.

maxLength180

permissions: Array<string\>

Available permissions for the Keyless SSL for the current user requesting the item.

port: number

The keyless SSL port used to communicate between Cloudflare and the client’s Keyless SSL server.

maxLength65535

status: "active" | "deleted"

Status of the Keyless SSL.

One of the following:

"active"

"deleted"

tunnel?: [Tunnel](https://developers.cloudflare.com/api/typescript/resources/keyless%5Fcertificates#%28resource%29%20keyless%5Fcertificates%20%3E%20%28model%29%20tunnel%20%3E%20%28schema%29) { private\_ip, vnet\_id } 

Configuration for using Keyless SSL through a Cloudflare Tunnel.

private\_ip: string

Private IP of the Key Server Host.

vnet\_id: string

Cloudflare Tunnel Virtual Network ID.

modified\_on?: string

When the certificate was last modified.

formatdate-time

policy\_restrictions?: string

The policy restrictions returned by the API. This field is returned in responses when a policy has been set. The API accepts the “policy” field in requests but returns this field as “policy\_restrictions” in responses.

Specifies the region(s) where your private key can be held locally for optimal TLS performance. Format is a boolean expression, for example: “(country: US) or (region: EU)”

priority?: number

The order/priority in which the certificate will be used in a request. The higher priority will break ties across overlapping ‘legacy\_custom’ certificates, but ‘legacy\_custom’ certificates will always supercede ‘sni\_custom’ certificates.

signature?: string

The type of hash used for the certificate.

status?: "active" | "expired" | "deleted" | 2 more

Status of the zone’s custom SSL.

One of the following:

"active"

"expired"

"deleted"

"pending"

"initializing"

uploaded\_on?: string

When the certificate was uploaded to Cloudflare.

formatdate-time

### Create SSL Configuration

TypeScript

HTTPHTTP

TypeScriptTypeScript

PythonPython

GoGo

TerraformTerraform

```
import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const customCertificate = await client.customCertificates.create({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  certificate:
    '-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n',
});

console.log(customCertificate.id);
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
    "bundle_method": "ubiquitous",
    "custom_csr_id": "7b163417-1d2b-4c84-a38a-2fb7a0cd7752",
    "expires_on": "2016-01-01T05:20:00Z",
    "geo_restrictions": {
      "label": "us"
    },
    "hosts": [
      "example.com"
    ],
    "issuer": "GlobalSign",
    "keyless_server": {
      "id": "4d2844d2ce78891c34d0b6c0535a291e",
      "created_on": "2014-01-01T05:20:00Z",
      "enabled": false,
      "host": "example.com",
      "modified_on": "2014-01-01T05:20:00Z",
      "name": "example.com Keyless SSL",
      "permissions": [
        "#ssl:read",
        "#ssl:edit"
      ],
      "port": 24008,
      "status": "active",
      "tunnel": {
        "private_ip": "10.0.0.1",
        "vnet_id": "7365377a-85a4-4390-9480-531ef7dc7a3c"
      }
    },
    "modified_on": "2014-01-01T05:20:00Z",
    "policy_restrictions": "(country: US) or (region: EU)",
    "priority": 1,
    "signature": "SHA256WithRSA",
    "status": "active",
    "uploaded_on": "2014-01-01T05:20:00Z"
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "zone_id": "023e105f4ecef8ad9ca31a8372d0c353",
    "bundle_method": "ubiquitous",
    "custom_csr_id": "7b163417-1d2b-4c84-a38a-2fb7a0cd7752",
    "expires_on": "2016-01-01T05:20:00Z",
    "geo_restrictions": {
      "label": "us"
    },
    "hosts": [
      "example.com"
    ],
    "issuer": "GlobalSign",
    "keyless_server": {
      "id": "4d2844d2ce78891c34d0b6c0535a291e",
      "created_on": "2014-01-01T05:20:00Z",
      "enabled": false,
      "host": "example.com",
      "modified_on": "2014-01-01T05:20:00Z",
      "name": "example.com Keyless SSL",
      "permissions": [
        "#ssl:read",
        "#ssl:edit"
      ],
      "port": 24008,
      "status": "active",
      "tunnel": {
        "private_ip": "10.0.0.1",
        "vnet_id": "7365377a-85a4-4390-9480-531ef7dc7a3c"
      }
    },
    "modified_on": "2014-01-01T05:20:00Z",
    "policy_restrictions": "(country: US) or (region: EU)",
    "priority": 1,
    "signature": "SHA256WithRSA",
    "status": "active",
    "uploaded_on": "2014-01-01T05:20:00Z"
  }
}
```