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
- Identify the Connect resource (
/connect/communities/{id}/chatter/feed-elements). - Prefer
ConnectApiApex namespace over REST when inside Apex — same capability, better typing. - Pagination via
nextPageUrl— don't compute offsets manually. - Authenticate with Named Credential + OAuth for external callers.
- 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
?includewhere 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