# Update a variable

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

PATCH https://dashboard.alchemy.com/api/graphql/variables/{var_name}

Adds items to a GraphQL webhook variable, or removes items from it. The
JSON body has one key: `add` or `delete`, with a list of at most 10,000
items. A body with both keys gets a 400, so send one request to add and
one to remove.

Reference: https://www.alchemy.com/docs/data/webhooks/webhooks-api-endpoints/update-graphql-variable

## Headers

| Name | Type | Required | Description |
|------|------|----------|-------------|
| X-Alchemy-Token | string | Yes | Your team's auth token. Find it on the Webhooks page of the Alchemy dashboard. |

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| var_name | string | Yes | The variable name. |

## Code Examples

### cURL

```bash
curl --request PATCH \
  --url https://dashboard.alchemy.com/api/graphql/variables/string \
  --header 'Content-Type: application/json' \
  --header 'X-Alchemy-Token: string' \
  --data '{
  "add": [
    "string"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', 'X-Alchemy-Token': 'string'},
  body: JSON.stringify({add: ['string']})
};

fetch('https://dashboard.alchemy.com/api/graphql/variables/string', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://dashboard.alchemy.com/api/graphql/variables/string"

payload = { "add": ["string"] }
headers = {
    "Content-Type": "application/json",
    "X-Alchemy-Token": "string"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://dashboard.alchemy.com/api/graphql/variables/string"

	payload := strings.NewReader("{\n  \"add\": [\n    \"string\"\n  ]\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("X-Alchemy-Token", "string")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.patch("https://dashboard.alchemy.com/api/graphql/variables/string")
  .header("Content-Type", "application/json")
  .header("X-Alchemy-Token", "string")
  .body("{\n  \"add\": [\n    \"string\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://dashboard.alchemy.com/api/graphql/variables/string");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("X-Alchemy-Token", "string");
request.AddJsonBody("{\n  \"add\": [\n    \"string\"\n  ]\n}", false);
var response = await client.PatchAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /api/graphql/variables/{var_name}
method: PATCH
operation:
  operationId: UpdateGraphqlVariable
  responses:
    '200':
      description: Changed the variable's items
      content:
        application/json:
          schema:
            properties: {}
            type: object
            description: Construct a type with a set of properties K of type T
            additionalProperties: false
          examples:
            Example 1:
              value: {}
    '400':
      description: Invalid input
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Invalid update operation
                name: ValidationError
    '401':
      description: Requires authentication
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Unauthenticated request.
                name: AuthError
    '503':
      description: Variable service unavailable
      content:
        application/json:
          schema:
            description: |-
              The error body. `name` is null for the statuses that have no name, such as
              404 and 429.
            properties:
              message:
                type: string
              name:
                type: string
                nullable: true
            required:
              - message
              - name
            type: object
            additionalProperties: false
          examples:
            Example 1:
              value:
                message: Error adding to graphQL variable
                name: ServerError
  description: |-
    Adds items to a GraphQL webhook variable, or removes items from it. The
    JSON body has one key: `add` or `delete`, with a list of at most 10,000
    items. A body with both keys gets a 400, so send one request to add and
    one to remove.
  summary: Update a variable
  tags:
    - Webhooks
  security:
    - team_api_key: []
  parameters:
    - description: The variable name.
      in: path
      name: var_name
      required: true
      schema:
        type: string
  requestBody:
    required: true
    content:
      application/json:
        schema:
          anyOf:
            - type: object
              required:
                - add
              additionalProperties: false
              properties:
                add:
                  type: array
                  items:
                    type: string
                  maxItems: 10000
                  description: The items to add.
                  nullable: true
            - type: object
              required:
                - delete
              additionalProperties: false
              properties:
                delete:
                  type: array
                  items:
                    type: string
                  maxItems: 10000
                  description: The items to remove.
                  nullable: true
```
