# Connect REST API Patterns

> Use Connect REST API for Chatter, feeds, communities, and CMS content instead of querying underlying SObjects. NOT for custom business object CRUD — use integration/graphql-api-patterns.

- Skill: `pranavnagrecha/connect-rest-api-patterns` (Agent Skill, multi-file: 7 files)
- Install (CLI): `npx skillmds add pranavnagrecha/connect-rest-api-patterns`
- Raw SKILL.md: https://api.skillmd.com/api/skills/pranavnagrecha/connect-rest-api-patterns/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: PranavNagrecha (https://skillmd.com/u/pranavnagrecha)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/pranavnagrecha/connect-rest-api-patterns

---


# Connect REST API Patterns

Connect REST API exposes Chatter feeds, CMS content, Experience Cloud, and moderation APIs with richer shapes and side-effects than raw SObject access. Use it when the business operation is 'post a feed item with mentions' or 'publish CMS content' rather than 'insert FeedItem row'.

## Adoption Signals

Chatter posts with mentions / rich text, CMS content authoring, community moderation, reports filters at scale.

- Required when the standard REST/SOAP APIs would force the consumer to assemble Chatter feed elements by hand.
- Required for Experience Cloud surfaces where the same payload feeds both UI rendering and external clients.

## Recommended Workflow

1. Identify the Connect resource (`/connect/communities/{id}/chatter/feed-elements`).
2. Prefer `ConnectApi` Apex namespace over REST when inside Apex — same capability, better typing.
3. Pagination via `nextPageUrl` — don't compute offsets manually.
4. Authenticate with Named Credential + OAuth for external callers.
5. Test with low-privilege users to catch perm gaps before go-live.

## Key Considerations

- Connect API respects sharing; raw SObject queries as System Admin can mask issues.
- Response payloads are verbose; request only the fields you need via `?include` where supported.
- CMS endpoints require Experience Cloud license.
- Chatter posts via Connect create notifications — posting from a trigger can cascade.

## Worked Examples (see `references/examples.md`)

- *Post feed item with mention* — Notify record owner
- *CMS content publish* — Publish a Knowledge article

## Common Gotchas (see `references/gotchas.md`)

- **Missing community context** — Post appears in wrong feed.
- **Sharing mismatch** — Integration user can't post on behalf of another.
- **Verbose payload bloat** — Response 500kB.

## Top LLM Anti-Patterns (full list in `references/llm-anti-patterns.md`)

- Inserting FeedItem directly when mentions matter
- Manual pagination math
- Missing community context

## Official Sources Used

- Apex REST & Callouts — https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts.htm
- Named Credentials — https://help.salesforce.com/s/articleView?id=sf.named_credentials_about.htm
- Connect REST API — https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/
- Private Connect — https://help.salesforce.com/s/articleView?id=sf.private_connect_overview.htm
- Bulk API 2.0 — https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/
- Pub/Sub API — https://developer.salesforce.com/docs/platform/pub-sub-api/guide/intro.html

