{
  "schema_version": 2,
  "id": "integrate/redis-data-integration/reference/cli/redis-di-set-context",
  "title": "redis-di set-context",
  "url": "https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-set-context/",
  "summary": "Creates or updates a context",
  "aliases": [
    "/integrate/redis-data-integration/reference/cli/redis-di-add-context/",
    "/integrate/redis-data-integration/reference/cli/redis-di-delete-all-contexts/",
    "/integrate/redis-data-integration/ingest/reference/cli/redis-di-set-context/"
  ],
  "tags": [
    "redis-di"
  ],
  "last_updated": "2026-09-18T16:41:35+01:00",
  "page_type": "content",
  "content_hash": "79941a734616475c434f1b65481fffd9373f1cc61e3a78b51e7af59da2c1dd9b",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Creates or updates a context in the `~/.redis-di` context file. A context stores an API connection\nso you don't have to pass the connection options on every command. `set-context` merges only the\noptions you give on the command line, preserving the rest, and does not change which context is\nactive; use [`use-context`](https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-use-context)\nfor that. See the\n[CLI reference overview](https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli#contexts)\nfor more about contexts.\n\nSecrets (the password and the Redis Cloud user key) are never stored in a context, so `set-context`\nrejects `--password` and `--user-key`."
    },
    {
      "id": "usage",
      "title": "Usage",
      "role": "syntax",
      "text": "[code example]\n\nThe connection is set from the global options `--api-url`, `--user`, `--account-key`, `--cacert`,\nand `--insecure`."
    },
    {
      "id": "options",
      "title": "Options",
      "role": "parameters",
      "text": "| Option                | Description                                                                                   |\n| :-------------------- | :-------------------------------------------------------------------------------------------- |\n| `--unset-user`        | Clear the stored user, so the context authenticates without a user.                           |\n| `--unset-account-key` | Clear the stored account key, so the context authenticates without a Redis Cloud account key. |\n\nThis command also accepts the\n[global options](https://redis.io/docs/latest/integrate/redis-data-integration/reference/cli/redis-di#global-options)."
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    }
  ],
  "examples": [
    {
      "id": "usage-ex0",
      "language": "plaintext",
      "code": "redis-di set-context <name> [flags]",
      "section_id": "usage"
    },
    {
      "id": "example-ex0",
      "language": "bash",
      "code": "# Create or update a context for a VM or Kubernetes installation\nredis-di set-context prod --api-url https://rdi.example.com --user default --cacert /etc/rdi/ingress-ca.crt\n\n# Create or update a context that skips TLS verification\nredis-di set-context dev --api-url https://localhost:8443 --insecure",
      "section_id": "example"
    }
  ]
}
