# Salesforce API REST

> Implements interactions with the Salesforce API using REST protocols to manage customer relationship data effectively.

- Skill: `paulpas/salesforce-api-rest` (Agent Skill)
- Install (CLI): `npx skillmds@latest add paulpas/salesforce-api-rest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/paulpas/salesforce-api-rest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: paulpas (https://skillmd.com/u/paulpas)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/paulpas/salesforce-api-rest

---






# Salesforce API - REST Integration

Implements RESTful interactions with the Salesforce API to manage and automate customer relationship data effectively.

## When to Use
- To retrieve and manipulate Salesforce records programmatically.
- When implementing integrations with third-party applications.
- For automated reporting and data synchronization with CRM systems.
- When interacting with Salesforce data in bulk for performance optimization.

## Core Workflow
1. **Authenticate with Salesforce** — Use OAuth 2.0 to obtain access and refresh tokens for API access.
   **Checkpoint:** Ensure tokens are securely stored and refreshed.
2. **Make API Calls** — Structure HTTP requests to Salesforce endpoints for data retrieval or record updates.
   **Checkpoint:** Confirm correct HTTP methods (GET, POST, PATCH, DELETE) are used based on action.
3. **Handle Responses** — Parse JSON responses from Salesforce and handle errors appropriately.
   **Checkpoint:** Validate response structure against expectations and log error messages for failed requests.

## Implementation Patterns
### Pattern 1: Authenticating with Salesforce
```python
import requests

def authenticate(client_id, client_secret, username, password):
    url = "https://login.salesforce.com/services/oauth2/token"
    payload = {"grant_type": "password",
               "client_id": client_id,
               "client_secret": client_secret,
               "username": username,
               "password": password}
    response = requests.post(url, data=payload)
    response.raise_for_status()  # Raise error for bad requests
    return response.json()  # Return access token and instance URL
```

### Pattern 2: Retrieving Salesforce Records
```python

def get_records(object_name, access_token, instance_url):
    url = f"{instance_url}/services/data/vXX.0/sobjects/{object_name}/"
    headers = {"Authorization": f"Bearer {access_token}"}
    response = requests.get(url, headers=headers)
    response.raise_for_status()
    return response.json()
```

## Constraints
### MUST DO
- Always use OAuth 2.0 authentication for API access.
- Log all API requests and responses for auditing purposes.
### MUST NOT DO
- Store sensitive credentials directly in the codebase.
- Exceed Salesforce API limits, which could lead to temporary lockouts.

---

## Live References

> Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.

- [Salesforce REST API Documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/)
- [REST API Quick Start Guide](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart.htm)
- [REST API Resource Reference](https://developer.salesforce.com/docs/atlas.en-us.api_rest/meta/api_rest/resources_list.htm)
- [Salesforce OAuth 2.0 Authentication](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/auth_used_for_interacting_with_other_systems.htm)
- [REST API Bulk Operations Best Practices](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_bulk_insert_delete_query.htm)

