{"schema_version":"1.0","publisher":"Primitive SDKs","canonical_url":"https://test.abhinandan.one/cli-overview/cli-generic-api-access","markdown_url":"https://test.abhinandan.one/cli-overview/cli-generic-api-access.md","article":{"id":"e15c8673-70f9-4284-a975-47b0fcb149c2","article_slug":"cli-generic-api-access","parent_article_slug":"cli-overview","parent_article_title":"What is the Primitive CLI?","kind":"reference","published_at":"2026-08-11T18:54:56.784969+00:00","keywords":["primitive list-operations","primitive emails:list-emails","primitive describe","api-command","generated API commands","operation manifest CLI"],"meta_description":"Every generated Primitive API operation is callable from the primitive CLI as tag:operation-id, with list-operations and describe for discovery.","og_image_url":null,"source_file_paths":["cli-node/src/oclif/commands/agent-upgrade.ts"],"recording_id":null,"replayable":false,"task_name":"Direct API Access and Generic Commands","category":"CLI","summary":null,"description":"Call any generated Primitive API operation directly from the CLI without waiting for a dedicated task-oriented command, and explore the full operation manifest with list-operations, describe, and completion helpers.","content_kind":"repo_page","content_markdown":"The `primitive` CLI exposes every operation in the [operation manifest](operation-manifest) as a generic command, in addition to the task-oriented commands (`primitive send`, `primitive functions deploy`, and so on) documented elsewhere. Use the generic form when a task-oriented command doesn't exist yet, or when you need full schema parity with the underlying OpenAPI operation.\n\n## Generic operation commands\n\nEvery generated operation is callable directly as `tag:command`, where the command name is the kebab-cased operation id from the manifest:\n\n```bash\nprimitive emails:list-emails\nprimitive sending:reply-to-email\n```\n\nReach for the task-oriented commands (`primitive send`, `primitive reply`, `primitive memories`, `primitive routes`) for normal workflows. The generic `tag:operation-id` form stays available for compatibility and full schema parity, and exposes every field the OpenAPI schema declares rather than a curated subset:\n\n```bash\nprimitive send --to alice@example.com --body \"Hello\"\n```\n\n## Listing every operation\n\n`primitive list-operations` prints the full [operation manifest](operation-manifest) as JSON: every operation's command name, HTTP method, path, parameters, and inlined request/response JSON Schemas.\n\n```bash\nprimitive list-operations\n```\n\nPipe it through `jq` to inspect a single operation's shape without probing the server with malformed payloads:\n\n```bash\nprimitive list-operations | jq '.[] | select(.command == \"send-email\")'\nprimitive list-operations | jq '.[] | select(.command == \"send-email\") | .requestSchema'\n```\n\nThis is the same manifest data the CLI's generic `api-command` path and `describe` helper read from; `list-operations` is the raw dump for scripting and agent tooling.\n\n## Describing an operation\n\n`primitive describe` prints one operation's manifest entry, by command name: method, path, parameters, and the inlined request/response schemas. Use it instead of `list-operations | jq` when you already know which operation you want:\n\n```bash\nprimitive describe send-email\n```\n\nThe response schema is derived from the operation's 200/201 envelope with the `data` field peeled off, so what's printed is the shape you actually get back, not the full `{ success, data, meta }` envelope.\n\n## api-client plumbing\n\nEvery command, generic or task-oriented, builds its request client with `createAuthenticatedCliApiClient`, a wrapper over the shared [PrimitiveApiClient](primitive-api-client) from `@primitivedotdev/api-core`. It resolves the API key (the `--api-key` flag, `PRIMITIVE_API_KEY`, or saved OAuth login credentials) and the base URL, then hands back an authenticated client that each command passes to a specific generated operation function.\n\nErrors from any generated operation call go through a shared error-payload extractor (`extractErrorPayload`) and a shared printer (`writeErrorWithHints`), so the error code, message, gates, and request id read the same whether you called a task-oriented command or a bare `tag:operation-id` command. A 401 additionally triggers an unauthorized hint pointing at re-authentication.\n\n## Shell completion and endpoint test redirects\n\nBash/zsh/powershell/fish completion setup and the internal `endpoints-test-redirect` helper (exercised by `primitive routes-test` and `primitive functions-test-function`) are covered on [Shell Completion and Endpoint Test Redirects](cli-completion-and-utilities).\n\n## Next steps\n\n<CardGroup cols={2}>\n\n<Card title=\"Operation Manifest Reference\" href=\"operation-manifest\">\n\nLook up the exact fields every manifest entry carries: command name, method, path, parameters, and inlined schemas.\n\n</Card>\n\n<Card title=\"PrimitiveApiClient\" href=\"primitive-api-client\">\n\nUnderstand the host-aware client every generated command and SDK method builds on, and its PrimitiveApiError shape.\n\n</Card>\n\n<Card title=\"What is the Primitive CLI?\" href=\"cli-overview\">\n\nSee how command groups, oclif, and the generated operation surface fit together.\n\n</Card>\n\n<Card title=\"Shell Completion and Endpoint Test Redirects\" href=\"cli-completion-and-utilities\">\n\nSet up completion scripts and use the endpoints-test-redirect helper.\n\n</Card>\n\n</CardGroup>","canonical_base_url":"https://test.abhinandan.one","seo_indexing_enabled":true,"last_modified":"2026-08-21T18:22:43.359885+00:00","video_url":null,"voiceover_url":null,"tools_used":[],"demonstrated_by":[],"steps":[],"related_links":[],"intro":null,"prerequisites":[],"verification":[],"troubleshooting":[],"suggest_edit_url":"https://github.com/abhi-browzer/primitive-sdks/edit/main/cli-node/src/oclif/commands/agent-upgrade.ts","raise_issue_url":"https://github.com/abhi-browzer/primitive-sdks/issues/new?title=Docs+feedback%3A+Direct+API+Access+and+Generic+Commands&body=Page%3A+https%3A%2F%2Ftest.abhinandan.one%2Fcli-generic-api-access","page_feedback_enabled":true,"verified_ref":null,"verified_at":"2026-08-11T18:38:45.205849+00:00"}}