> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add aliases in bulk

> Create up to 1000 aliases for one CDN resource in a single request.

The request is atomic: if any item is invalid, nothing is created and the errors are returned per item, in the same order as the request items. An item whose hostname is already an alias of the same CDN resource is reported in `exists` and left unchanged.

The aliases limit of your account is checked against the items that would be created.

<Info>
  This endpoint is in beta. <Badge color="blue">BETA</Badge>
</Info>


## OpenAPI

````yaml /api-reference/services_docs_mintlify_enriched/cdn_api.yaml post /cdn/aliases/add
openapi: 3.1.0
info:
  title: Gcore OpenAPI – CDN API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: cbe2bf61926c
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: CDN service
    description: Information about the current state of the CDN service in your account.
  - name: CDN resources
  - name: Origins
  - name: Rules
    description: >-
      Rules allow to set up custom settings for certain file types or paths.

      By default, the rule inherits all options values from the related CDN
      resource.


      Each option in rule settings can be in one of the following states:

      - **Inherit** - Option is not added to the rule. Option inherits its value
      from the CDN resource settings. In this case, the option value is
      **null**.

      - **ON** - Option is added to the rule and enabled. Option values
      configured in the rule will override values from the CDN resource
      settings.

      - **OFF** - Option is added to the rule and disabled. Option will be
      turned off.
  - name: Rule templates
  - name: Presets
    description: >-
      A preset is a predefined set of CDN resource or rule settings that can be
      applied to an object in a single request.


      Once a preset is applied to an object, the options included in the preset
      cannot be edited on that object until the preset is unapplied.
  - name: SSL certificates
  - name: Let's Encrypt certificates
  - name: CA certificates
  - name: Aliases
    description: >-
      An alias is a hostname you own that is served with the settings of one of
      your CDN resources and with

      its own SSL certificate. Aliases must be enabled for your account.
  - name: CDN activity logs
    description: |-
      Get the history of users requests to CDN.
      It contains requests made both via the API and via the control panel.

      The following methods are not tracked in the activity logs:
      - HEAD
      - OPTIONS
  - name: Log viewer
    description: >-
      Log viewer provides you with general information about CDN operation. This
      information does not contain all possible

      sets of fields and restricted by time. To receive full data, use Logs
      Uploader.
  - name: Logs uploader
    description: >-
      Logs uploader allows you to upload logs with desired format to desired
      storages.


      Consists of three main parts:

      - **Policies** - rules that define which logs are uploaded and how they
      are uploaded.

      - **Targets** - destinations where logs are uploaded.

      - **Configs** - combinations of logs uploader policies, targets and
      resources to which they are applied.
  - name: Tools
  - name: Statistics
    description: >-
      Consumption statistics is updated in near real-time as a standard
      practice.

      However, the frequency of updates can vary, but they are typically
      available within a 24-hour period.

      Exceptions, such as maintenance periods, may delay data beyond 24 hours
      until servers resume and fill in the missing statistics.
  - name: Advanced analytics
    description: >-
      Advanced analytics allows to get statistics about unique visitors,
      traffic, and requests for countries, directories, browsers, devices, and
      operation systems for up to 90 days starting from today.


      Advanced analytics API is based on the [GraphQL
      framework](https://graphql.org/).


      Advanced analytics API has one single endpoint:

       https://api.gcore.com/cdn/advanced/v2/query

      You can pass the query parameters as a JSON object in the payload of a
      POST request to this endpoint.

      You can use curl to make requests to the Advanced analytics API.
      Alternatively, you can use a GraphQL client

      to construct queries and pass requests to the Advanced analytics API.


      You can write queries in GraphQL much like in SQL: specify the data set
      (CDN resource), the metrics

      to retrieve (such as unique visitors and traffic), and filter or group by
      dimensions (for example, a country).
  - name: Origin shielding
  - name: IP addresses list
  - name: Purge history
paths:
  /cdn/aliases/add:
    post:
      tags:
        - Aliases
      summary: Add aliases in bulk
      description: >-
        Create up to 1000 aliases for one CDN resource in a single request.


        The request is atomic: if any item is invalid, nothing is created and
        the errors are returned per item, in the same order as the request
        items. An item whose hostname is already an alias of the same CDN
        resource is reported in `exists` and left unchanged.


        The aliases limit of your account is checked against the items that
        would be created.
      operationId: add-aliases
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AliasesAddPayload'
      responses:
        '200':
          description: Successful.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AliasesAddResponse'
        '400':
          description: Validation failed, or the aliases limit of your account is reached.
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/AliasesAddError'
                  - $ref: '#/components/schemas/AliasesLimitError'
        '403':
          description: Aliases are not enabled for your account.
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from gcore import Gcore

            client = Gcore(
                api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
            )
            response = client.cdn.aliases.create_multiple(
                items=[{
                    "cname": "shop.customer.com"
                }],
                resource_id=4567,
            )
            print(response.created)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/G-Core/gcore-go\"\n\t\"github.com/G-Core/gcore-go/cdn\"\n\t\"github.com/G-Core/gcore-go/option\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.CDN.Aliases.NewMultiple(context.TODO(), cdn.AliasNewMultipleParams{\n\t\tItems: []cdn.AliasNewMultipleParamsItem{{\n\t\t\tCname: \"shop.customer.com\",\n\t\t}},\n\t\tResourceID: 4567,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Created)\n}\n"
components:
  schemas:
    AliasesAddPayload:
      type: object
      required:
        - resource_id
        - items
      properties:
        resource_id:
          type: integer
          description: ID of the CDN resource whose settings the aliases are served with.
          example: 4567
        items:
          type: array
          minItems: 1
          maxItems: 1000
          description: Aliases to create.
          items:
            $ref: '#/components/schemas/AliasBulkItem'
    AliasesAddResponse:
      type: object
      properties:
        created:
          type: array
          description: Aliases created by this request.
          items:
            $ref: '#/components/schemas/AliasBulkItemResult'
        exists:
          type: array
          description: >-
            Items whose hostname was already an alias of the CDN resource.
            Nothing was changed for them.
          items:
            $ref: '#/components/schemas/AliasBulkItemResult'
      example:
        created:
          - id: 1
            cname: shop.example.com
            status: pending
            ssl_status: pending
        exists:
          - id: 7
            cname: www.example.com
            status: active
            ssl_status: issued
    AliasesAddError:
      title: Bulk validation error
      type: object
      properties:
        errors:
          type: object
          description: >-
            Error descriptions per field of the request. `items` holds one
            object per request item, in request order; an empty object means the
            item is valid.
          properties:
            resource_id:
              type: array
              items:
                type: string
            items:
              type: array
              items:
                type: object
                additionalProperties:
                  type: array
                  items:
                    type: string
      example:
        errors:
          items:
            - {}
            - cname:
                - Hostname www.example.com already exists.
    AliasesLimitError:
      title: Aliases limit exceeded
      type: object
      properties:
        errors:
          type: array
          description: >-
            The aliases limit of your account does not allow the requested
            number of new aliases.
          items:
            type: string
          example:
            - 'Aliases limit exceeded: limit=100, current=98, requested_new=3.'
    AliasBulkItem:
      type: object
      required:
        - cname
      properties:
        cname:
          type: string
          description: Alias hostname.
          example: shop.example.com
        ssl_id:
          type: integer
          nullable: true
          description: >-
            ID of your own SSL certificate to serve for the alias. A Let's
            Encrypt certificate issued for one of your CDN resources cannot be
            used. Omit it to have a Let's Encrypt certificate issued
            automatically.
          example: 890
        automated:
          type: boolean
          description: >-
            How the alias certificate is managed. Defaults to `true` when
            `ssl_id` is omitted and to `false` when `ssl_id` is passed.
          example: false
        challenge_type:
          allOf:
            - $ref: '#/components/schemas/AliasChallengeType'
          description: >-
            Domain validation method used to issue the Let's Encrypt
            certificate. Defaults to `dns_01`. Can be passed only when
            `automated` is `true`.
    AliasBulkItemResult:
      type: object
      properties:
        id:
          type: integer
          description: Alias ID.
          example: 123
        cname:
          type: string
          description: Alias hostname.
          example: shop.example.com
        status:
          $ref: '#/components/schemas/AliasStatus'
        ssl_status:
          $ref: '#/components/schemas/AliasSslStatus'
    AliasChallengeType:
      type: string
      description: >-
        Domain validation method used to issue the Let's Encrypt certificate for
        the alias.


        Possible values:

        - `dns_01` – Validation via a CNAME record for `_acme-challenge.<alias
        hostname>`, shown in `ssl_provisioning.acme_delegation`.

        - `http_01` – Validation via an HTTP request to the alias hostname. The
        alias hostname must point to your CDN CNAME, shown in
        `ssl_provisioning.http_validation`. The request is served with the
        settings of the alias's CDN resource, so they must not block or redirect
        `/.well-known/acme-challenge/`.
      enum:
        - dns_01
        - http_01
      example: http_01
    AliasStatus:
      type: string
      description: >-
        Alias status.


        Possible values:

        - `inactive` – The alias or its CDN resource is disabled; the alias is
        not served.

        - `pending` – The alias configuration has not reached the CDN yet.

        - `http_only` – The alias is served over HTTP only.

        - `active` – The alias is served over HTTP and HTTPS.
      enum:
        - inactive
        - pending
        - http_only
        - active
      example: active
    AliasSslStatus:
      type: string
      nullable: true
      description: >-
        Outcome of the certificate we manage for the alias.


        Possible values:

        - `pending` – A certificate attempt is in progress, or was stopped by
        pausing the alias and starts again after it is resumed.

        - `issued` – The latest attempt succeeded.

        - `failed` – The latest attempt ended without a certificate.

        - `null` – No certificate is managed for the alias: the alias uses a
        certificate you provided, or is automated and has never opened an
        attempt.
      enum:
        - pending
        - issued
        - failed
      example: issued
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234_abcdef`
      type: apiKey
      in: header
      name: Authorization

````