Skip to main content
POST
/
cdn
/
origin_groups
Python
import os
from gcore import Gcore

client = Gcore(
    api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
)
origin_groups = client.cdn.origin_groups.create(
    name="YourOriginGroup",
    sources=[{
        "source": "yourwebsite.com"
    }],
)
print(origin_groups)
{
  "id": 1,
  "name": "YourOriginGroup",
  "sources": [
    {
      "source": "yourwebsite.com",
      "backup": false,
      "enabled": true,
      "tag": "default",
      "host_header_override": null
    },
    {
      "source": "1.2.3.4:5500",
      "backup": true,
      "enabled": true,
      "tag": "default",
      "host_header_override": null
    },
    {
      "origin_type": "s3",
      "config": {
        "s3_type": "amazon",
        "s3_bucket_name": "my-bucket",
        "s3_region": "eu-west-1",
        "s3_access_key_id": "SECRET_VALUE",
        "s3_secret_access_key": "SECRET_VALUE",
        "s3_auth_type": "awsSignatureV4"
      },
      "backup": true,
      "enabled": true,
      "tag": "default",
      "host_header_override": null
    }
  ],
  "use_next": true,
  "proxy_next_upstream": [
    "error",
    "timeout",
    "invalid_header",
    "http_500",
    "http_502",
    "http_503",
    "http_504"
  ],
  "auth_type": "none",
  "path": "",
  "has_related_resources": true
}

Authorizations

Authorization
string
header
required

API key for authentication. Make sure to include the word apikey, followed by a single space and then your token. Example: apikey 1234$abcdef

Body

application/json

Create an origin group with host origins, or mixed host and S3 origins.

name
string
required

Origin group name.

Example:

"YourOriginGroup"

sources
(Host Source · object | S3 Source · object)[]
required
use_next
boolean

Defines whether to use the next origin from the origin group if origin responds with the cases specified in proxy_next_upstream. If you enable it, you must specify cases in proxy_next_upstream.

Possible values:

  • true - Option is enabled.
  • false - Option is disabled.
Example:

true

proxy_next_upstream
string[]

Defines cases when the request should be passed on to the next origin.

Possible values:

  • error - an error occurred while establishing a connection with the origin, passing a request to it, or reading the response header
  • timeout - a timeout has occurred while establishing a connection with the origin, passing a request to it, or reading the response header
  • invalid_header - a origin returned an empty or invalid response
  • http_403 - a origin returned a response with the code 403
  • http_404 - a origin returned a response with the code 404
  • http_429 - a origin returned a response with the code 429
  • http_500 - a origin returned a response with the code 500
  • http_502 - a origin returned a response with the code 502
  • http_503 - a origin returned a response with the code 503
  • http_504 - a origin returned a response with the code 504
Example:
[
"error",
"timeout",
"invalid_header",
"http_500",
"http_502",
"http_503",
"http_504"
]
auth_type
string
default:none
deprecated

Deprecated. No longer necessary. Defaults to none.

Origin authentication type.

Possible values:

  • none - Used for public origins.
  • awsSignatureV4 - Used for S3 storage.
Example:

"none"

Response

Successful.

Origin group with host origins, or mixed host and S3 origins using inline origin_type and config in sources.

id
integer
required

Origin group ID.

Example:

1

name
string
required

Origin group name.

Example:

"YourOriginGroup"

sources
(Host Source · object | S3 Source · object)[]
required

List of origin sources in the origin group. Each entry can be a host origin or an S3 origin.

Host origins have a source field with the hostname or IP. S3 origins have origin_type: s3 and a config object with S3 credentials. Both types can be mixed in the same origin group.

A host origin source.

Example:
[
{
"source": "yourwebsite.com",
"backup": false,
"enabled": true,
"tag": "default",
"host_header_override": null
},
{
"source": "1.2.3.4:5500",
"backup": true,
"enabled": true,
"tag": "default",
"host_header_override": null
},
{
"origin_type": "s3",
"config": {
"s3_type": "amazon",
"s3_bucket_name": "my-bucket",
"s3_region": "eu-west-1",
"s3_access_key_id": "SECRET_VALUE",
"s3_secret_access_key": "SECRET_VALUE",
"s3_auth_type": "awsSignatureV4"
},
"backup": true,
"enabled": true,
"tag": "default",
"host_header_override": null
}
]
use_next
boolean

Defines whether to use the next origin from the origin group if origin responds with the cases specified in proxy_next_upstream. If you enable it, you must specify cases in proxy_next_upstream.

Possible values:

  • true - Option is enabled.
  • false - Option is disabled.
Example:

true

proxy_next_upstream
string[]

Defines cases when the request should be passed on to the next origin.

Possible values:

  • error - an error occurred while establishing a connection with the origin, passing a request to it, or reading the response header
  • timeout - a timeout has occurred while establishing a connection with the origin, passing a request to it, or reading the response header
  • invalid_header - a origin returned an empty or invalid response
  • http_403 - a origin returned a response with the code 403
  • http_404 - a origin returned a response with the code 404
  • http_429 - a origin returned a response with the code 429
  • http_500 - a origin returned a response with the code 500
  • http_502 - a origin returned a response with the code 502
  • http_503 - a origin returned a response with the code 503
  • http_504 - a origin returned a response with the code 504
Example:
[
"error",
"timeout",
"invalid_header",
"http_500",
"http_502",
"http_503",
"http_504"
]
auth_type
string
default:none
deprecated

Deprecated. No longer necessary. Defaults to none.

Origin authentication type.

Possible values:

  • none - Used for public origins.
  • awsSignatureV4 - Used for S3 storage.
Example:

"none"

path
string
deprecated

Deprecated. No longer necessary. Omit this field and the default origin path behavior will be used.

Origin path prefix.

Example:

""

Defines whether the origin group has related CDN resources.

Possible values:

  • true - Origin group has related CDN resources.
  • false - Origin group does not have related CDN resources.
Example:

true