API

Add hostname

POSThttps://api.visitors.now/v1/project/hostnames

Adds a hostname that can send tracking events for the project.

Request

index.ts
const res = await fetch("https://api.visitors.now/v1/project/hostnames", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${VISITORS_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    hostname: "*.visitors.now",
  }),
});

const data = await res.json();

Body parameters

hostname

stringrequired

Hostname to allow. Wildcards like *.example.com are supported.

Response

{
  "hostnames": ["visitors.now", "*.visitors.now"]
}