一键导入
sf-api
Raw REST API and GraphQL requests via sf CLI. Use for custom endpoints, GraphQL queries/mutations, and arbitrary HTTP calls to Salesforce APIs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Raw REST API and GraphQL requests via sf CLI. Use for custom endpoints, GraphQL queries/mutations, and arbitrary HTTP calls to Salesforce APIs.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Salesforce CLI (sf command) reference and best practices. Use this skill when working with Salesforce development, deployment, org management, data operations, or CI/CD workflows. Covers modern sf v2 commands from version 2.140.6 (June 28, 2026).
Data operations including SOQL queries, single record CRUD, bulk import/export/update, and search.
Org management commands including listing, displaying, opening, and creating Scratch Orgs and Sandboxes.
Agentforce agent management commands including creation, activation, deactivation, and testing.
Apex development commands including class and trigger generation, anonymous execution, unit test running, and debug log management.
Authentication commands for connecting to Salesforce orgs. Includes Web Login, JWT, SFDX-URL, and Access Token flows.
| name | sf-api |
| description | Raw REST API and GraphQL requests via sf CLI. Use for custom endpoints, GraphQL queries/mutations, and arbitrary HTTP calls to Salesforce APIs. |
sf api OperationsCommands for making raw API requests to Salesforce. These are essential for
calling custom Apex REST endpoints, GraphQL queries/mutations, or any
Salesforce API not covered by a dedicated sf data or sf project command.
[!NOTE] Both commands are currently in beta. The
--jsonglobal flag is NOT supported consistently on these commands.sf api request rest --jsonis rejected by CLI 2.140.6;sf api request graphql --jsoncan exit 0 with no stdout. Prefer raw output,--include,--stream-to-file, and shell piping (| python3 -m json.toolor| jq) for formatted output.
Make an authenticated HTTP request using the Salesforce REST API. Authentication is handled automatically from the target org credentials.
# GET request - describe an object
sf api request rest "/services/data/v66.0/sobjects/Account/describe" \
--target-org myOrg
# GET request - query record count
sf api request rest "/services/data/v66.0/limits/recordCount" \
--target-org myOrg
# POST request - create a record via REST
sf api request rest "/services/data/v66.0/sobjects/Account" \
--target-org myOrg \
--method POST \
--header "Content-Type:application/json" \
--body '{"Name":"Test Account"}'
# Call a custom Apex REST endpoint
sf api request rest "/services/apexrest/ugent/v1/status" \
--target-org myOrg \
--method GET
# POST to custom Apex REST with body
sf api request rest "/services/apexrest/ugent/v1/session" \
--target-org myOrg \
--method POST \
--header "Content-Type:application/json" \
--body '{"org_id":"00D...","user_id":"005..."}'
# PATCH request - update record fields
sf api request rest "/services/data/v66.0/sobjects/Account/001..." \
--target-org myOrg \
--method PATCH \
--header "Content-Type:application/json" \
--body '{"Name":"Updated Name"}'
# DELETE request
sf api request rest "/services/data/v66.0/sobjects/Account/001..." \
--target-org myOrg \
--method DELETE
# Stream response to file (for large responses)
sf api request rest "/services/data/v66.0/sobjects/Account/describe" \
--target-org myOrg \
--stream-to-file account-describe.json
# Read body from stdin
echo '{"Name":"Pipe Account"}' | sf api request rest \
"/services/data/v66.0/sobjects/Account" \
--target-org myOrg \
--method POST \
--header "Content-Type:application/json" \
--body -
| Flag | Description |
|---|---|
[URL] | Salesforce API endpoint (relative to instance URL) |
-o, --target-org | Target org (required) |
-X, --method | HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, TRACE |
-H, --header | HTTP header in key:value format (repeatable) |
-b, --body | Body content, @file to read from file, - for stdin, "" for empty |
-f, --file | JSON file with header, body, method, and URL values |
-S, --stream-to-file | Stream response to file |
-i, --include | Include HTTP status and headers in output |
The URL is relative to the org's instance URL:
/services/data/v66.0/sobjects/{Object}/{Id} - SObject REST/services/data/v66.0/query?q=... - REST SOQL/services/data/v66.0/search?q=... - REST SOSL/services/data/v66.0/composite - Composite API/services/data/v66.0/composite/tree/{Object} - SObject Tree/services/apexrest/{path} - Custom Apex REST endpointsExecute a GraphQL query or mutation against the Salesforce GraphQL API.
# Query accounts
sf api request graphql \
--target-org myOrg \
--body 'query { uiapi { query { Account { edges { node { Id Name { value } } } } } } }'
# Query with variables from stdin
echo '{"query":"query($id:ID!){uiapi{query{Account(filter:{Id:{eq:$id}}){edges{node{Name{value}}}}}}}","variables":{"id":"001..."}}' \
| sf api request graphql \
--target-org myOrg \
--body -
# Mutation - create a record
sf api request graphql \
--target-org myOrg \
--body 'mutation { uiapi { AccountCreate(input:{Account:{Name:"GraphQL Account"}}){Record{Id Name{value}}} } }'
# Read query from file
sf api request graphql \
--target-org myOrg \
--body query.graphql
| Flag | Description |
|---|---|
-o, --target-org | Target org (required) |
--body | GraphQL statement (required): inline text, file path, or - for stdin |
--api-version | Override API version |
-S, --stream-to-file | Stream response to file |
-i, --include | Include HTTP status and headers in output |
uiapi namespace{ value } objects, not raw valuesCreate, Update, Delete suffixes on object names@file to load complex queries from .graphql filesUnlike most other sf commands, sf api does not consistently support
--json. The REST or GraphQL response body is output directly, usually as JSON.
To parse:
# Pretty-print JSON output
sf api request rest "/services/data/v66.0/sobjects/Account/describe" \
--target-org myOrg | python3 -m json.tool
# Extract a field with jq
sf api request rest "/services/data/v66.0/sobjects/Account/describe" \
--target-org myOrg | jq '.fields | length'
# Save to file
sf api request rest "/services/data/v66.0/sobjects/Account/describe" \
--target-org myOrg > account-describe.json