Platform primitives /Functions /

Functions API reference

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

Upgrading from Lambda compatibility mode

If you’re using the older Lambda compatibility mode for functions, consider upgrading to get access to the full context object below. Learn more.

# Netlify-specific Context object

The Context object exposes the following properties:

# account

An object containing Netlify team account information. The id property in the object holds the 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 requires a custom domain

Since the netlify.app domain is used by many customers, it is listed in the Mozilla Foundation’s Public Suffix List, which prevents setting cookies across subdomains.

# deploy

An object containing Netlify deploy information with the following property:

  • context: the context of the deploy that the function belongs to.
  • id: unique ID of the deploy that the function belongs to.
  • published: a boolean that indicates whether or not the function belongs to the current published deploy .

# 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.
  • postalCode: postal (zip) code of the location. We support all regional formats, so the format will vary.

# ip

A string containing the client IP address.

# params

An object containing the parameters set for the function’s path in the configuration object and the values they receive from the incoming request URL.

For example, for a function configured to run at /pets/:name, the params value for a request to /pets/boo will be {"name":"boo"}.

To access the query string, use request.url instead.

# 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, https://petsof.netlify.app or https://www.petsofnetlify.com.

# waitUntil

context.waitUntil() is a function accepting a promise, allowing you to extend the function’s execution until that promise it completed, without blocking the response to the client from being sent. Learn more.

Usage notes:

  • This method is available for functions deployed on or after March 20, 2025. To test locally, use the latest version of the Netlify CLI.
  • The duration which is reported in logs, reported in metrics, exported via log drains and used for billing includes the full duration of the function until it completes, including any asynchronous operations. Typically, the end-user is receiving the response before the function completes all async work.
  • The Netlify function can run until its execution time limit. That includes all async work.

# Netlify global object

This global object exposes the following properties:

# Netlify.context

The Netlify-specific context object.

This property is available within the scope of the function handler. If accessed from outside the handler, it returns null.

# Netlify.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.