service-cloud-rest-api

Use this skill when integrating with Salesforce Service Cloud REST APIs — specifically the Knowledge REST API (/knowledgeManagement/ for authoring, /support/knowledgeWithSEO/ for guest retrieval) and the Messaging for In-App and Web (MIAW) Enhanced Chat API. Trigger keywords: Knowledge article retrieval, data category filtering, URL-name lookup, Enhanced Chat API, legacy Chat REST API migration. NOT for generic REST API callouts from Apex (use apex__http-callouts), NOT for Salesforce REST API CRUD on standard objects, NOT for Einstein Bot configuration.

Best use case

service-cloud-rest-api is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use this skill when integrating with Salesforce Service Cloud REST APIs — specifically the Knowledge REST API (/knowledgeManagement/ for authoring, /support/knowledgeWithSEO/ for guest retrieval) and the Messaging for In-App and Web (MIAW) Enhanced Chat API. Trigger keywords: Knowledge article retrieval, data category filtering, URL-name lookup, Enhanced Chat API, legacy Chat REST API migration. NOT for generic REST API callouts from Apex (use apex__http-callouts), NOT for Salesforce REST API CRUD on standard objects, NOT for Einstein Bot configuration.

Teams using service-cloud-rest-api should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/service-cloud-rest-api/SKILL.md --create-dirs "https://raw.githubusercontent.com/PranavNagrecha/AwesomeSalesforceSkills/main/skills/apex/service-cloud-rest-api/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/service-cloud-rest-api/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How service-cloud-rest-api Compares

Feature / Agentservice-cloud-rest-apiStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use this skill when integrating with Salesforce Service Cloud REST APIs — specifically the Knowledge REST API (/knowledgeManagement/ for authoring, /support/knowledgeWithSEO/ for guest retrieval) and the Messaging for In-App and Web (MIAW) Enhanced Chat API. Trigger keywords: Knowledge article retrieval, data category filtering, URL-name lookup, Enhanced Chat API, legacy Chat REST API migration. NOT for generic REST API callouts from Apex (use apex__http-callouts), NOT for Salesforce REST API CRUD on standard objects, NOT for Einstein Bot configuration.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Service Cloud REST API

This skill activates when a practitioner needs to call Salesforce Service Cloud REST APIs — either the Knowledge REST API (both the internal authoring surface and the guest-facing SEO retrieval surface) or the Messaging for In-App and Web (MIAW) Enhanced Chat API. It covers endpoint selection, authentication differences, data category filtering, legacy Chat REST API migration, and common integration patterns.

---

## Before Starting

Gather this context before working on anything in this domain:

- **API version:** The URL-name lookup for Knowledge articles requires API version 44.0 or later. Confirm the org's minimum API version before building integrations.
- **Authentication context:** The `/knowledgeManagement/` endpoint family requires an authenticated session (internal users, agents, or Apex callouts with a session ID). The `/support/knowledgeWithSEO/` endpoint family supports unauthenticated guest access — used for Experience Cloud portals and self-service sites. Using the wrong endpoint for the wrong context causes 401 errors or missing article results.
- **Chat API version in use:** Determine whether the org still uses the legacy Chat REST API (force.com/chat/rest/) or has migrated to Enhanced Chat API (Messaging for In-App and Web, MIAW). The legacy Chat REST API was retired on February 14, 2026. Any org still calling legacy Chat REST endpoints after that date receives failures.
- **Data category structure:** Knowledge article retrieval via data category filter requires knowing the data category group developer name and the category developer name. These must be URL-encoded in query parameters.
- **Knowledge article type metadata:** The v1 Knowledge REST API uses article type-specific endpoints. The v2 (unified) Knowledge REST API treats all articles uniformly under a single `knowledge__kav` object type.

---

## Core Concepts

### Knowledge REST API — Two Distinct Endpoint Families

Salesforce exposes two separate REST API families for Knowledge, each with a different authentication model and purpose:

**Internal/Authoring (`/knowledgeManagement/`):**
- Base path: `/services/data/vXX.X/knowledgeManagement/`
- Requires a valid authenticated Salesforce session (OAuth access token or Apex session ID)
- Used for: drafting, publishing, translating, managing article lifecycle, retrieving article content for agents
- Key resources: `/articles`, `/articles/{articleId}`, `/articleTypes`, `/articleTypes/{articleTypeName}/suggestedArticles`
- Returns full article field content including internal-only fields

**Guest/SEO Retrieval (`/support/knowledgeWithSEO/`):**
- Base path: `/services/data/vXX.X/support/knowledgeWithSEO/`
- Supports unauthenticated access when used with an Experience Cloud site that has guest user access enabled
- Used for: self-service portals, public knowledge bases, Experience Cloud deflection pages
- Returns articles filtered to those published and accessible to the guest user profile
- URL-name-based lookup available from API v44+: `/support/knowledgeWithSEO/articles?urlName=my-article-url-name`

Mixing up these two families is the most common integration error: an Apex callout using `/knowledgeManagement/` will fail in an Aura/LWC guest context; a portal site using `/support/knowledgeWithSEO/` will not return unpublished drafts.

### Data Category Filtering

Knowledge articles are organized into data categories (hierarchical classification trees). The REST API supports filtering by data category using query parameters:

- `categoryGroup` — developer name of the data category group (e.g., `Products`)
- `category` — developer name of the specific category (e.g., `Laptops`)
- `navigationType` — `standard` (default) or `classifyingArticles` — controls whether parent/child categories are included

Example query string: `?categoryGroup=Products&category=Laptops`

Data category names are case-sensitive and must match the developer name exactly, not the label. A mismatch returns an empty result set with no error, which is a common silent failure mode.

Visibility of articles by data category is also governed by the user's data category visibility settings. An authenticated user who lacks visibility to a category will receive an empty result even if articles exist — there is no permission error thrown.

### Legacy Chat REST API vs. Enhanced Chat API (MIAW)

Salesforce had two separate live-chat REST API surfaces:

**Legacy Chat REST API (retired February 14, 2026):**
- Base path: `https://<instance>.salesforce.com/chat/rest/`
- Used the `X-LIVEAGENT-API-VERSION` header and `X-LIVEAGENT-SESSION-KEY` header pair
- Required a separate chat endpoint hostname distinct from the Salesforce instance URL
- Session lifecycle: `/System/SessionId` → `/Chasitor/ChasitorInit` → polling `/System/Messages`

**Enhanced Chat API — Messaging for In-App and Web (MIAW):**
- Part of the Salesforce Omni-Channel Messaging platform
- Uses standard OAuth 2.0 bearer tokens — no custom headers required
- Conversation lifecycle managed via Salesforce Platform Event streaming and REST resources under `/services/data/vXX.X/connect/messaging/`
- Supports persistent conversation history, async messaging, and rich media — capabilities not available in legacy Chat REST API
- Agent-facing events flow through Omni-Channel rather than a long-poll loop

After February 14, 2026, any integration still targeting legacy Chat REST endpoints (`/chat/rest/`) receives HTTP errors. Migrating requires replacing the entire client session lifecycle — there is no backward-compatible wrapper.

---

## Common Patterns

### Pattern 1: Knowledge Article Retrieval with Data Category Filter (Authenticated)

**When to use:** An Apex class, Visualforce page, or LWC (in authenticated context) needs to programmatically fetch Knowledge articles filtered to a specific product line or topic.

**How it works:**

1. Obtain an OAuth access token or use the current session ID in Apex (`UserInfo.getSessionId()`).
2. Construct the request to `/services/data/v62.0/knowledgeManagement/articles` with query params.
3. Pass `categoryGroup` and `category` as query parameters.
4. Deserialize the JSON response into Apex wrapper classes.

Key request shape:
```
GET /services/data/v62.0/knowledgeManagement/articles?categoryGroup=Products&category=Laptops&pageSize=10
Authorization: Bearer <access_token>
```

Response contains `articles` array with `id`, `title`, `summary`, `urlName`, `articleType`, `publishStatus`, `lastPublishedDate`.

**Why not SOQL directly:** SOQL on `Knowledge__kav` does not respect data category visibility for guests, and does not produce SEO-friendly URL name lookups. REST API respects the full sharing and visibility stack.

### Pattern 2: Guest-Facing Article Lookup by URL Name (Experience Cloud)

**When to use:** An Experience Cloud self-service site needs to render a full Knowledge article using its URL slug (e.g., `/help/how-to-reset-password`), without requiring the visitor to log in.

**How it works:**

1. Enable Knowledge for the Experience Cloud site and set the guest user profile's data category visibility.
2. Make an unauthenticated REST call (or via Connected App with the site's guest user context) to:
   ```
   GET /services/data/v62.0/support/knowledgeWithSEO/articles?urlName=how-to-reset-password
   ```
3. The response returns the full article body, metadata, and related categories for the matching URL name.
4. If the URL name does not match any article visible to the guest profile, the response returns an empty `articles` array (not a 404).

**Why not the authoring endpoint:** `/knowledgeManagement/` requires authentication and returns draft articles — unsuitable for public-facing rendering.

### Pattern 3: Migrating Legacy Chat REST API to Enhanced Chat API (MIAW)

**When to use:** Any org that has live code or integrations using the legacy Chat REST API (`/chat/rest/`) that must be migrated before or after the February 14, 2026 retirement deadline.

**How it works:**

1. Audit all integration points calling `<instance>.salesforce.com/chat/rest/` — check Apex `HttpRequest` callouts, external middleware, and mobile SDKs.
2. Provision an Enhanced Messaging Channel in Setup > Messaging Settings. Select "In-App and Web" channel type.
3. Replace `X-LIVEAGENT-*` header-based session initiation with an OAuth 2.0 Connected App flow.
4. Replace the long-poll `GET /System/Messages` loop with Platform Event subscription to `ConversationIntelligenceEvent__e` or use the MIAW SDK for web/mobile.
5. Map legacy transcript objects (`LiveChatTranscript`) to their MIAW equivalents (`MessagingSession`).

**Why not keep legacy Chat REST:** The endpoint is retired and returns errors post-February 14, 2026. There is no official compatibility shim.

---

## Decision Guidance

| Situation | Recommended Approach | Reason |
|---|---|---|
| Authenticated agent needs article list filtered by data category | `GET /knowledgeManagement/articles?categoryGroup=X&category=Y` | Authoring endpoint respects agent sharing model |
| Unauthenticated guest needs to render article by URL slug | `GET /support/knowledgeWithSEO/articles?urlName=<slug>` | Guest-friendly endpoint, supports URL-name lookup (v44+) |
| Org uses legacy Chat REST API (post-Feb 2026) | Migrate to MIAW Enhanced Chat API | Legacy Chat REST API retired Feb 14, 2026 |
| Need to check if a category group/category name is correct | Query data category visibility in Setup and use developer names | Labels ≠ developer names; mismatch silently returns empty results |
| LWC in Experience Cloud needs to fetch articles without exposing credentials | Use `getRecord` Lightning Data Service or Apex `@AuraEnabled` with `without sharing` scoped to Knowledge | Avoids exposing OAuth tokens in client-side JavaScript |
| Need article content for AI summarization in Apex | Use `/knowledgeManagement/articles/{id}` with `Accept: application/json` | Returns full article body fields unlike SOQL which truncates rich text |

---

## Recommended Workflow

Step-by-step instructions for an AI agent or practitioner working on this task:

1. **Identify authentication context** — Determine whether the integration will run as an authenticated internal user/agent or as an unauthenticated guest. This determines which endpoint family (`/knowledgeManagement/` vs. `/support/knowledgeWithSEO/`) to use and whether a Connected App with OAuth is needed.
2. **Confirm API version** — Verify the org's minimum API version. URL-name lookup requires v44+. Use the highest available API version (e.g., v62.0 for Spring '25) to access the latest resource shapes.
3. **Check data category configuration** — For any category-filtered retrieval, confirm the data category group and category developer names in Setup > Data Categories. Verify the user or guest profile has the correct data category visibility assignments.
4. **Audit legacy Chat REST usage** — Run a codebase search for `/chat/rest/` and `X-LIVEAGENT-API-VERSION`. Any hit requires MIAW migration. Document each call site with its session lifecycle step.
5. **Construct and test REST calls** — Build the endpoint URL, add required headers (`Authorization: Bearer`, `Content-Type: application/json`), and validate the response shape in Workbench or Postman before implementing in Apex.
6. **Implement Apex callout with proper error handling** — Wrap `Http.send()` in try/catch, check `HttpResponse.getStatusCode()` for 200/201 vs. 4xx/5xx, parse the JSON body, and handle the empty-array case for data category mismatches.
7. **Validate with a Review Checklist pass** — Confirm no legacy Chat REST references remain, no hardcoded category names, correct endpoint family for the auth context, and that test coverage includes the empty-result case.

---

## Review Checklist

Run through these before marking work in this area complete:

- [ ] Correct endpoint family used for authentication context (`/knowledgeManagement/` for authenticated, `/support/knowledgeWithSEO/` for guest)
- [ ] API version is v44+ if URL-name lookup is used
- [ ] Data category developer names (not labels) used in query parameters
- [ ] No remaining references to legacy Chat REST API (`/chat/rest/` or `X-LIVEAGENT-*` headers)
- [ ] Empty-array response handled explicitly (not treated as an error, but not silently ignored)
- [ ] OAuth access token or session ID is not exposed in client-side JavaScript
- [ ] Apex test class mocks the `HttpResponse` for both success and empty-result scenarios

---

## Salesforce-Specific Gotchas

Non-obvious platform behaviors that cause real production problems:

1. **Data category mismatch returns empty array, not an error** — If the `categoryGroup` or `category` parameter value does not match an existing developer name (including case), the API returns `{"articles": [], "total": 0}` with HTTP 200. There is no error message. This silently breaks filtering and is indistinguishable from "no articles exist" without inspecting Setup.
2. **Legacy Chat REST API is retired** — Any callout to `<instance>.salesforce.com/chat/rest/` after February 14, 2026 returns an error. There is no deprecation grace period or backward-compatible redirect. Orgs that missed the migration deadline must treat this as an emergency remediation.
3. **`/knowledgeManagement/` returns drafts; `/support/knowledgeWithSEO/` does not** — The authoring endpoint includes draft and archived articles in results when the `publishStatus` filter is omitted. A portal that accidentally uses the authoring endpoint (with an admin session) may display unpublished articles to visitors.
4. **Guest user data category visibility must be explicitly configured** — Even if articles are published, an Experience Cloud guest user will receive an empty result from `/support/knowledgeWithSEO/` unless the guest user profile has been granted data category visibility in Setup > Data Category Visibility. This is a separate setting from the article's publication status.
5. **URL-name uniqueness is not enforced across article types** — If two articles of different types share the same `urlName`, the `/support/knowledgeWithSEO/articles?urlName=<slug>` endpoint may return multiple results or only the first match depending on API version. Use article-type-specific filtering when URL names are not guaranteed unique.

---

## Output Artifacts

| Artifact | Description |
|---|---|
| Endpoint selection decision | Documented choice of `/knowledgeManagement/` vs. `/support/knowledgeWithSEO/` with justification |
| Apex callout class | `HttpRequest`/`HttpResponse` wrapper with JSON deserialization and empty-result handling |
| Data category parameter map | Validated developer names for `categoryGroup` and `category` query parameters |
| MIAW migration checklist | List of legacy Chat REST call sites replaced with Enhanced Chat API equivalents |

---

## Related Skills

- `architect/service-cloud-architecture` — Service Cloud solution architecture including Knowledge as a deflection engine and channel strategy
- `agentforce/einstein-copilot-for-service` — Einstein Article Recommendations and Service Replies that consume Knowledge articles internally

Related Skills

service-account-credential-rotation

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing credential rotation for integration users, connected apps, named credentials, and OAuth client secrets in Salesforce. Covers rotation cadence, zero-downtime handover, secret storage, and detection of stale credentials. Triggers: 'rotate integration user password', 'connected app secret rotation', 'named credential rotation', 'stale service account', 'zero downtime secret rotation'. NOT for end-user password policies.

ip-relaxation-and-restriction

8
from PranavNagrecha/AwesomeSalesforceSkills

Design IP-based access controls: profile login IP ranges, org-wide trusted IPs, IP relaxation per profile, and the interaction with MFA and SSO. Trigger keywords: login IP range, trusted IP, IP relaxation, restricted IP, IP allowlist, login hours. Does NOT cover: network-layer firewalling, corporate VPN design, or Shield Event Monitoring.

experience-cloud-security

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when configuring access controls, sharing, or site security for authenticated or guest Experience Cloud (community) users: external OWD, Sharing Sets, Share Groups, CSP, clickjack protection, guest user record access. NOT for internal sharing model configuration (use sharing-and-visibility).

wire-service-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing or reviewing Lightning Web Components that use `@wire`, Lightning Data Service, UI API, or the GraphQL wire adapter, especially for reactive parameters, cache behavior, and refresh strategy. Triggers: 'wire service', 'refreshApex', 'reactive parameter', 'getRecord', 'wire vs imperative Apex'. NOT for component communication or generic lifecycle issues when data provisioning is not the main concern.

headless-experience-cloud

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building custom frontends (React, Vue, mobile, static sites) that consume Salesforce CMS content via the Connect REST API headless delivery endpoint. Triggers: 'headless Salesforce CMS', 'deliver CMS content to external frontend', 'React app Salesforce content API', 'custom frontend Experience Cloud data', 'CMS delivery channel API'. NOT for standard Experience Builder site development. NOT for CMS Connect (3rd-party CMS federation into Experience Builder). NOT for Experience Cloud LWC components rendered inside a site.

experience-cloud-search-customization

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring or extending search on an Experience Cloud site — covering Search Manager scope configuration, LWR vs Aura search component selection, federated search setup, guest user search access, and custom search result components. NOT for SOSL/SOQL query development. NOT for internal Salesforce global search or Einstein Search for agents.

experience-cloud-multi-idp-sso

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring multiple identity providers (OIDC and/or SAML) on a single Experience Cloud site or across tenant-specific portals in the same org — covering auth provider registration, Start SSO URL routing, Federation ID mapping, RegistrationHandler implementation, and simultaneous SP+IdP topology. Trigger keywords: multiple identity providers Experience Cloud, multi-tenant SSO community portal, vendor and citizen portal same site, OIDC SAML both on login page, tenant-specific login routing community. NOT for internal Salesforce employee SSO configuration. NOT for single auth provider setups — see experience-cloud-authentication for basic SSO.

experience-cloud-lwc-components

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building custom LWC components for Experience Cloud (Experience Builder sites, LWR portals, Aura-based communities). Covers community context imports, guest user Apex access patterns, navigation API differences between LWR and Aura, and JS-meta.xml target configuration for Experience Builder exposure. NOT for internal LWC components deployed to Lightning App Builder or standard record pages (see lwc/lwc-development). NOT for Aura community components. Trigger keywords: build LWC for Experience Cloud, custom component community portal LWC, guest user LWC component, community context import salesforce, lightningCommunity target, @salesforce/community, guest Apex.

experience-cloud-authentication

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when building custom login pages, social SSO flows, self-registration flows, or passwordless OTP login for Experience Cloud (community) sites. Trigger keywords: custom login page Experience Cloud, social SSO community portal, passwordless login Experience Cloud, self-registration custom flow, headless authentication community, auth provider OIDC SAML site. NOT for internal SSO configuration (use identity/sso skills). NOT for standard username/password authentication with no customization.

experience-cloud-api-access

8
from PranavNagrecha/AwesomeSalesforceSkills

Use this skill when configuring or troubleshooting API access for Experience Cloud external users and guest users: guest user Apex data access, Customer Community Plus or Partner Community REST/SOAP API access, external user OAuth scopes, and sharing enforcement on API responses. Trigger keywords: Experience Cloud API access external user, community user REST API, guest user API limits, Customer Community API permissions, external user OAuth. NOT for internal Salesforce API authentication, non-community OAuth flows, or internal user API security.

rest-api-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

Use when designing, implementing, or reviewing Salesforce REST API integration — covering CRUD operations on sObjects, SOQL-based queries, paginated result sets, Composite requests, Composite Batch, and sObject Tree. Triggers: 'Salesforce REST API', 'composite API', 'nextRecordsUrl', 'sObject Tree', 'REST CRUD', 'REST pagination', 'API limits', 'OAuth Bearer token'. NOT for GraphQL API queries, Bulk API 2.0 large-data-load jobs, Metadata API deployments, or custom Apex REST endpoints.

rest-api-pagination-patterns

8
from PranavNagrecha/AwesomeSalesforceSkills

REST API pagination for inbound and outbound integrations: Salesforce QueryMore, cursor-based, offset-based, Link header, page-size tuning, rate limit interaction. NOT for Bulk API (use bulk-api-patterns). NOT for GraphQL connection pagination (use graphql-api-patterns).