Functions /

Functions API reference

This page provides a full reference of the Netlify Functions API.

# Netlify-specific Context object

The Context object exposes the following properties:

  • account: an object containing Netlify team account information with the following property:

    • id: unique ID of the team that the site and function belong to.
  • cookies: a simplified interface for reading and storing cookies:

    • cookies.get(name): reads a cookie with a given name from the incoming request.

    • cookies.set(options): sets a cookie on the outgoing response, using the same format as the options value in the CookieStore.set web standard.

    • cookies.delete(name) or cookies.delete(options): adds an instruction to the outgoing response for the client to delete a cookie. Following the CookieStore.delete web standard, accepts a string representing the name of the cookie, or an options object.

      Setting cookies across subdomains only works for custom domains is listed in the Mozilla Foundation’s Public Suffix List, which prevents setting cookies across subdomains. You can only set a cookie for all subdomains if your site uses a custom domain instead of

  • deploy: an object containing Netlify deploy information with the following property:

    • id: unique ID of the deploy that the function belongs to.
  • geo: an object containing geolocation data for the client with the following properties:

    • city: name of the city.
    • country:
      • code: ISO 3166 code for the country.
      • name: name of the country.
    • latitude: latitude of the location.
    • longitude: longitude of the location.
    • subdivision:
      • code: ISO 3166 code for the country subdivision.
      • name: name of the country subdivision.
    • timezone: timezone of the location.
  • ip: a string containing the client IP address.

  • requestId: a string containing the Netlify request ID; for example, 01FDWR77JMF2DA1CHF5YA6H07C.

  • server: an object containing server metadata with the following property:

    • region: the region code where the deployment is running; for example, us-east-1.
  • site: an object containing Netlify site metadata with the following properties:

    • id: unique ID for the site; for example, 1d01c0c0-4554-4747-93b8-34ce3448ab95.
    • name: name of the site, its Netlify subdomain; for example, petsof.
    • url: URL representing the main address to your site. It can be either a Netlify subdomain or your own custom domain if you set one; for example, or

# Netlify global object

The Netlify global object exposes the following properties:

  • env: an object providing access to environment variables with the following properties:
    • delete(name): in the context of the invocation, deletes an environment variable with a given name.
    • get(name): returns the string value of an environment variable with a given name; if the environment variable is not defined, undefined is returned.
    • has(name): returns a boolean value containing true if an environment variable with a given name exists, and false otherwise.
    • set(name, value): in the context of the invocation, sets an environment variable with a given name and value.
    • toObject(): returns a plain object containing all the environment variables and their values.