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

# Create Cookie

Use this API to create a new cookie.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0",
    "title": "Consent & Preferences - Cookie Consent (Swagger)"
  },
  "tags": [
    {
      "name": "Cookies"
    }
  ],
  "paths": {
    "/v1/cookies": {
      "post": {
        "responses": {
          "201": {
            "description": "Created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "ID of the cookie."
                    },
                    "name": {
                      "type": "string",
                      "description": "Name of the cookie."
                    },
                    "description": {
                      "type": "string",
                      "description": "Purpose of the cookie."
                    },
                    "host": {
                      "type": "string",
                      "description": "Host of the cookie."
                    },
                    "path": {
                      "type": "string",
                      "description": "Path of the cookie."
                    },
                    "source": {
                      "type": "string",
                      "description": "The source from which the cookie is created.",
                      "example": "MANUAL"
                    },
                    "cookieLifeSpan": {
                      "type": "string",
                      "description": "Lifespan of the cookie."
                    },
                    "httpOnly": {
                      "type": "boolean",
                      "description": "Flag indicating the cookie is Http only or not."
                    },
                    "secure": {
                      "type": "boolean",
                      "default": false,
                      "description": "Flag indicating the cookie is secure or not."
                    },
                    "length": {
                      "type": "integer",
                      "description": "Length of the cookie lifespan."
                    },
                    "durationType": {
                      "type": "integer",
                      "description": "Unit of time for the cookie lifespan."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request.\n\n**Possible reason**: Invalid or missing parameter passed."
          },
          "401": {
            "description": "Unauthorized."
          },
          "403": {
            "description": "Forbidden.\n\n**Possible reasons**:\nYou do not have enough permissions to invoke this endpoint."
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Internal Server Error. \n\n**Possible reason**: Cookie with the same name and host already exists."
          }
        },
        "summary": "Create Cookie",
        "description": "Use this API to create a new cookie.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cookieName": {
                    "type": "string",
                    "description": "Name of the cookie."
                  },
                  "lifespan": {
                    "type": "string",
                    "enum": [
                      "PERSISTENT",
                      "SESSION"
                    ],
                    "description": "Lifespan of the cookie."
                  },
                  "host": {
                    "type": "string",
                    "description": "Host of the cookie."
                  },
                  "description": {
                    "type": "string",
                    "description": "Description of the cookie, It should be 1075 characters or less.",
                    "default": "\"\""
                  },
                  "customCategoryName": {
                    "type": "string",
                    "description": "Unique identifier of a cookie category (Cookie Category ID).",
                    "example": "C0001"
                  },
                  "length": {
                    "type": "integer",
                    "description": "Length of the cookie lifespan, enter a number greater than 0 if this is a persistent cookie, otherwise leave as 0.",
                    "default": 0
                  },
                  "durationType": {
                    "type": "integer",
                    "enum": [
                      1,
                      7,
                      30,
                      365
                    ],
                    "description": "Unit of time for the cookie lifespan, enter 1 (for days), 7 (for weeks), 30 (for months), or 365 (for years) based on the time unit the cookie lifespan is measured in.",
                    "example": "1, 7, 30, 365"
                  },
                  "domainCookieCategoryList": {
                    "type": "array",
                    "default": [],
                    "description": "A list of domain level categorizations for the Cookie.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "domainId": {
                          "type": "string",
                          "description": "ID of the domain."
                        },
                        "customCategoryName": {
                          "type": "string",
                          "description": "ID of a cookie category (cookie category id)."
                        },
                        "thirdParty": {
                          "type": "boolean",
                          "description": "Flag indicating if the cookie is third-party or first-party, use False if the cookie is first-Party."
                        }
                      }
                    }
                  }
                },
                "required": [
                  "cookieName",
                  "lifespan",
                  "host",
                  "customCategoryName",
                  "durationType"
                ]
              }
            }
          },
          "description": "Configuration for the new cookie",
          "x-examples": {
            "application/json": {
              "cookieName": "AnotherTest Cookie",
              "lifespan": "SESSION",
              "host": "test.com",
              "description": "",
              "customCategoryName": "C0001",
              "length": 0,
              "durationType": 1,
              "domainCookieCategoryList": [
                {
                  "domainId": "1f7d9ea1-3f02-4b0a-b1ba-19b3c8e0b38b",
                  "customCategoryName": "C0002",
                  "thirdParty": true
                }
              ]
            }
          }
        },
        "operationId": "createNewCookie",
        "tags": [
          "Cookies"
        ]
      }
    }
  },
  "security": [
    {
      "oauth2": []
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "metrics-enabled": false,
    "proxy-enabled": true
  },
  "x-onetrust": {
    "spec-label": "Swagger 2",
    "links": {
      "Cookie Consent Knowledge Base": "https://my.onetrust.com/s/topic/0TO1Q000000ItRyWAK/cookie-compliance"
    }
  },
  "servers": [
    {
      "url": "https://customer.my.onetrust.com/api/cookiemanager"
    }
  ],
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://{$$.env.host}/api/access/v1/oauth/token",
            "scopes": {
              "COOKIE": "Cookie Scope gives the user access to read/write operations inside the Cookie Consent module.",
              "COOKIE_READ": "Cookie Read Scope gives the user read-only access to the Cookie Consent module.",
              "COOKIE_FREE": "Cookie free Scope gives free users access to apis having free scope associated to them inside the Cookie Consent module."
            }
          }
        }
      }
    }
  }
}
```