> ## Documentation Index
> Fetch the complete documentation index at: https://docs.worldvisagroup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage contexts

> Create, update, retrieve, and delete workflow contexts in WorldVisa through the dashboard or the REST API to power per-tenant and per-environment configuration.

WorldVisa lets you manage contexts through the WorldVisa dashboard, or the WorldVisa API. This lets you create, view, update, and delete context entities to suit your application's needs.

> [!WARNING]
>
> You can pass a maximum of five contexts per workflow trigger and the serialized `data` object for each context is limited to 64KB.

## Context object schema

When defining contexts, WorldVisa supports multiple formats per key-value pair that let you store and reference metadata relevant to your workflows and templates.

Each context consists of:

* A `type` (for example, tenant, app, or region).
* An `id` that uniquely identifies the specific context instance.
* An optional `data` object that holds additional properties available to your templates.

Supported data formats include:

```bash theme={null}
curl -L -g -X POST "${WV_API_URL}/v1/events/trigger" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}" \
-d '{
    "name": "workflowId",
    "to": { "subscriberId": "user123" },
    "payload": { "userName": "John" },
    "context": {
        "tenant": "acme-corp",
        "app": { "id": "jira" },
        "region": {
            "id": "us-east",
            "data": {
                "name": "US East",
                "timezone": "America/New_York",
                "currency": "USD"
            }
        }
    }
}'
```

## Create a Context

You can create a new context via the WorldVisa dashboard or API when you want to register reusable metadata. After creation, this context becomes available to all workflows and templates within your environment.

### Create a context via dashboard

Use the dashboard to manually define contexts that represent key business entities.

**1. Log in to the WorldVisa dashboard**

Open the WorldVisa Dashboard.

**2. Open Contexts**

In the WorldVisa dashboard sidebar, click **Contexts**.

**3. Create context**

![create context](https://mintcdn.com/wv-enterprise/nfMqNpG3TRk8Yj_D/images/developers/workflows/contexts/create-context.png?fit=max\&auto=format\&n=nfMqNpG3TRk8Yj_D\&q=85\&s=8d830f199f3d60a8df9c72934147a814)

**4. Complete the fields**

* **Identifier**: A unique identifier within that type (for example, acme-corp).
* **Context type**: A category such as tenant, app, or region.
* **Custom data (JSON)**: An optional JSON object that contains metadata, such as branding, plan, or region details.

**5. Save the context**

Review the fields, then click **Create context** to save.

![create context](https://mintcdn.com/wv-enterprise/nfMqNpG3TRk8Yj_D/images/developers/workflows/contexts/create-contexts.png?fit=max\&auto=format\&n=nfMqNpG3TRk8Yj_D\&q=85\&s=8c38e509f0910b262351cbc8bbecd15b)

### Create a context via API

WorldVisa provides an API to create a context. If a context with the same `type:id` combination already exists, then the request will fail.

```bash theme={null}
curl -L -g -X POST "${WV_API_URL}/v1/contexts" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}" \
-d '{
    "type": "tenant",
    "id": "acme-corp",
    "data": {
        "name": "Acme Corporation",
        "plan": "enterprise"
    }
}'
```

### Create a context via API (Just-in-time)

Contexts can also be created automatically when you trigger a workflow that includes a new context object. If the specified `type:id` doesn't exist, then WorldVisa automatically creates it before running the workflow.

```bash theme={null}
curl -L -g -X POST "${WV_API_URL}/v1/events/trigger" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}" \
-d '{
    "name": "workflowId",
    "to": { "subscriberId": "user@example.com" },
    "payload": { "userName": "John" },
    "context": {
        "tenant": "acme-corp",
        "app": "jira"
    }
}'
```

If a matching context already exists and you pass only a string identifier, WorldVisa reuses it without changing stored `data`. If you pass a rich object with a `data` field, WorldVisa replaces the stored `data` with the values from your trigger request. This upsert behavior applies to workflow triggers only.

Inbox and other subscriber-facing APIs find or create contexts but do not update existing `data`.

## Update a context

You can update a context's data payload at any time. The context `type` and `id` remain immutable. You can update existing context `data` through the dashboard, API, or by passing inline `data` on a workflow trigger.

#### Update a context via dashboard

**1. Log in to the WorldVisa dashboard**

Open the WorldVisa Dashboard.

**2. Open Contexts**

In the WorldVisa dashboard sidebar, click **Contexts**.

**3. Select the context**

Open the context you want to inspect or edit.

**4. Modify the data object**

Edit the JSON payload for this context in the editor.

**5. Save changes**

Your updates apply immediately to future workflow triggers.

### Update a context via API

WorldVisa provides an API to update an existing context. The `data` object is replaced entirely during updates (not merged). Include all fields you want to retain.

```bash theme={null}
curl -L -g -X PATCH "${WV_API_URL}/v1/contexts/tenant/acme-corp" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}" \
-d '{
    "data": {
        "plan": "premium",
        "region": "us-east"
    }
}'
```

## Retrieve a single context

You can retrieve a context to verify its data, confirm its creation, or inspect the metadata it holds.

### Retrieve a context via dashboard

**1. Log in to the WorldVisa dashboard**

Open the WorldVisa Dashboard.

**2. Open Contexts**

In the WorldVisa dashboard sidebar, click **Contexts**.

**3. View context details**

Click any context entry to see its details.

### Retrieve a context via API

WorldVisa provides an API to retrieve a single, specific context by providing its `type` and `id` in the URL.

```bash theme={null}
curl -L -g -X GET "${WV_API_URL}/v1/contexts/tenant/acme-corp" \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}"
```

## List or search for contexts

You can list all contexts in your environment or search for specific ones by context type or ID.

### List or search for contexts via dashboard

**1. Log in to the WorldVisa dashboard**

Open the WorldVisa Dashboard.

**2. Open Contexts**

In the WorldVisa dashboard sidebar, click **Contexts**.

**3. Search contexts**

Use the search bar to filter by context type or ID.

### List or search for contexts via API

WorldVisa provides an API that lists or searches available contexts. Use pagination and search parameters to retrieve subsets efficiently.

```bash theme={null}
curl -L -g -X GET "${WV_API_URL}/v1/contexts?search=acme" \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}"
```

## Delete a context

Delete a context if it's no longer needed. This action permanently removes the context from your WorldVisa environment.

> [!WARNING]
>
> Deleting a context cannot be undone. Ensure the context is no longer required by any active or historical workflows you might need to analyze.

### Delete a context via dashboard

**1. Log in to the WorldVisa dashboard**

Open the WorldVisa Dashboard.

**2. Open Contexts**

In the WorldVisa dashboard sidebar, click **Contexts**.

**3. Select the context to remove**

Click the context or the **...** icon on the row you want to remove.

**4. Confirm deletion**

A confirmation menu will appear.

![Delete](https://mintcdn.com/wv-enterprise/nfMqNpG3TRk8Yj_D/images/developers/workflows/contexts/delete.png?fit=max\&auto=format\&n=nfMqNpG3TRk8Yj_D\&q=85\&s=275150894344fe59438620592b70d9ec)

**5. Delete the context**

Select **Delete context** to confirm removal.

![Delete context](https://mintcdn.com/wv-enterprise/nfMqNpG3TRk8Yj_D/images/developers/workflows/contexts/delete-context.png?fit=max\&auto=format\&n=nfMqNpG3TRk8Yj_D\&q=85\&s=f8c90de4c14ee1d103f6c7d87154a9ca)

### Delete a context via API

WorldVisa provides an API that you can use to delete a context. Once deleted, the context will no longer be available for use in new workflow executions.

```bash theme={null}
curl -L -g -X DELETE "${WV_API_URL}/v1/contexts/tenant/acme-corp" \
-H 'Accept: application/json' \
-H "Authorization: ApiKey ${WV_API_KEY}"
```


## Related topics

- [How do contexts work in WorldVisa?](https://docs.worldvisagroup.com/developers/concepts/contexts.md)
- [Multi-tenancy](https://docs.worldvisagroup.com/developers/concepts/tenants.md)
- [Personalize Content](https://docs.worldvisagroup.com/developers/workflow/add-notification-content/personalize-content.md)
- [How do subscribers work in WorldVisa?](https://docs.worldvisagroup.com/developers/concepts/subscribers.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.