---
updatedAt: 2026-09-29T23:38:36.000Z
agentTools:
  projectIndex: https://dev.kevel.com/llms.txt
---

# Client-Side Requests and CORS

The Decision API supports CORS for Fetch requests. [GitHub's documentation has a good overview of CORS](https://developer.github.com/v3/#cross-origin-resource-sharing).

> ❗️
>
> If you make client-side requests to the Decision API and expect cookies in the response, you must pass the CORS headers described below.

The CORS preflight request looks like this:

```curl CORS Preflight Request
curl -i https://e-23.adzerk.net/api/v2/ -H "Origin: https://example.com/page.html" -X OPTIONS
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: accept, origin, content-type, content-length
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Origin: https://example.com/page.html
Date: Fri, 09 Jun 2017 20:33:34 GMT
Server: nginx/1.1.19
X-Powered-By: Express
Content-Length: 0
Connection: keep-alive
```

You must pass `credentials: "include"` in the Fetch `options` for the request to enable cross-domain requests. See the Fetch example below:

```html Client-Side Request Example
<!DOCTYPE html>
<script>
fetch("https://e-23.adzerk.net/api/v2", {
  method: "POST",
  credentials: "include",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    placements: [
      {
        divName: "testDiv",
        networkId: 23,
        siteId: 667480,
        adTypes: [5]
      }
    ]
  })
})
.then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
})
.then(data => {
  document.getElementById("testDiv").innerHTML = data.decisions.testDiv.contents[0].body;
})
.catch(error => {
  console.error('There was a problem with the fetch operation:', error);
});
</script>

<div id="testDiv">this text will be replaced by an ad</div>

```

The cookie returned in a response is the `azk` cookie with a user's User Key as its value. [Refer to the UserDB documentation](https://dev.kevel.com/docs/userdb-1) for more info.

> 📘
>
> The cookie will originate from the domain used to make the request. If you use a white-labeled domain to call the Decision API, you should expect cookies from that domain.