> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/connect/n8n-api/variables.md).

# Variables

Operations about variables

## Retrieve variables

> Retrieve variables from your instance.

```json
{"openapi":"3.0.0","info":{"title":"n8n Public API","version":"1.1.1"},"tags":[{"name":"Variables","description":"Operations about variables"}],"servers":[{"url":"/api/v1"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-N8N-API-KEY"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"limit":{"name":"limit","in":"query","description":"The maximum number of items to return.","required":false,"schema":{"type":"number","default":100,"maximum":250}},"cursor":{"name":"cursor","in":"query","description":"Paginate by setting the cursor parameter to the nextCursor attribute returned by the previous request's response. Default value fetches the first \"page\" of the collection. See pagination for more detail.","required":false,"style":"form","schema":{"type":"string"}}},"schemas":{"variableList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/variable"}},"nextCursor":{"type":"string","description":"Paginate through variables by setting the cursor parameter to a nextCursor attribute returned by a previous request. Default value fetches the first \"page\" of the collection.","nullable":true}}},"variable":{"type":"object","additionalProperties":false,"required":["key","value"],"properties":{"id":{"type":"string","readOnly":true},"key":{"type":"string"},"value":{"type":"string"},"type":{"type":"string","readOnly":true},"project":{"$ref":"#/components/schemas/project"}}},"project":{"type":"object","additionalProperties":false,"required":["name"],"properties":{"id":{"type":"string","readOnly":true},"name":{"type":"string"},"type":{"type":"string","readOnly":true}}}},"responses":{"unauthorized":{"description":"Unauthorized"}}},"paths":{"/variables":{"get":{"tags":["Variables"],"summary":"Retrieve variables","description":"Retrieve variables from your instance.","parameters":[{"$ref":"#/components/parameters/limit"},{"$ref":"#/components/parameters/cursor"},{"name":"projectId","in":"query","required":false,"explode":false,"allowReserved":true,"schema":{"type":"string"}},{"name":"state","in":"query","required":false,"schema":{"type":"string","enum":["empty"]}}],"responses":{"200":{"description":"Operation successful.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/variableList"}}}},"401":{"$ref":"#/components/responses/unauthorized"}}}}}}
```

## Create a variable

> Create a variable in your instance.

```json
{"openapi":"3.0.0","info":{"title":"n8n Public API","version":"1.1.1"},"tags":[{"name":"Variables","description":"Operations about variables"}],"servers":[{"url":"/api/v1"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-N8N-API-KEY"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"variable.create":{"type":"object","additionalProperties":false,"required":["key","value"],"properties":{"id":{"type":"string","readOnly":true},"key":{"type":"string"},"value":{"type":"string"},"type":{"type":"string","readOnly":true},"projectId":{"type":"string","nullable":true}}}},"responses":{"badRequest":{"description":"The request is invalid or provides malformed data."},"unauthorized":{"description":"Unauthorized"}}},"paths":{"/variables":{"post":{"tags":["Variables"],"summary":"Create a variable","description":"Create a variable in your instance.","requestBody":{"description":"Payload for variable to create.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/variable.create"}}},"required":true},"responses":{"201":{"description":"Operation successful."},"400":{"$ref":"#/components/responses/badRequest"},"401":{"$ref":"#/components/responses/unauthorized"}}}}}}
```

## Update a variable

> Update a variable from your instance.

```json
{"openapi":"3.0.0","info":{"title":"n8n Public API","version":"1.1.1"},"tags":[{"name":"Variables","description":"Operations about variables"}],"servers":[{"url":"/api/v1"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-N8N-API-KEY"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"variableId":{"name":"id","in":"path","description":"The ID of the variable.","required":true,"schema":{"type":"string"}}},"schemas":{"variable.create":{"type":"object","additionalProperties":false,"required":["key","value"],"properties":{"id":{"type":"string","readOnly":true},"key":{"type":"string"},"value":{"type":"string"},"type":{"type":"string","readOnly":true},"projectId":{"type":"string","nullable":true}}}},"responses":{"badRequest":{"description":"The request is invalid or provides malformed data."},"unauthorized":{"description":"Unauthorized"},"forbidden":{"description":"Forbidden"},"notFound":{"description":"The specified resource was not found."}}},"paths":{"/variables/{id}":{"put":{"tags":["Variables"],"summary":"Update a variable","description":"Update a variable from your instance.","parameters":[{"$ref":"#/components/parameters/variableId"}],"requestBody":{"description":"Payload for variable to update.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/variable.create"}}},"required":true},"responses":{"204":{"description":"Operation successful."},"400":{"$ref":"#/components/responses/badRequest"},"401":{"$ref":"#/components/responses/unauthorized"},"403":{"$ref":"#/components/responses/forbidden"},"404":{"$ref":"#/components/responses/notFound"}}}}}}
```

## Delete a variable

> Delete a variable from your instance.

```json
{"openapi":"3.0.0","info":{"title":"n8n Public API","version":"1.1.1"},"tags":[{"name":"Variables","description":"Operations about variables"}],"servers":[{"url":"/api/v1"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-N8N-API-KEY"},"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"variableId":{"name":"id","in":"path","description":"The ID of the variable.","required":true,"schema":{"type":"string"}}},"responses":{"unauthorized":{"description":"Unauthorized"},"notFound":{"description":"The specified resource was not found."}}},"paths":{"/variables/{id}":{"delete":{"tags":["Variables"],"summary":"Delete a variable","description":"Delete a variable from your instance.","parameters":[{"$ref":"#/components/parameters/variableId"}],"responses":{"204":{"description":"Operation successful."},"401":{"$ref":"#/components/responses/unauthorized"},"404":{"$ref":"#/components/responses/notFound"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.n8n.io/connect/n8n-api/variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
