---
title: "Get Open Tickets from Salesforce API"
url: "http://35.223.47.52/blog/get-open-tickets-from-salesforce-api/"
date: "2026-08-13T12:58:29+00:00"
modified: "2026-08-23T11:20:33+00:00"
type: "post"
---

# Get Open Tickets from Salesforce API

[Blog](http://35.223.47.52/blog) / [Tutorials](http://35.223.47.52/blogs/tutorials/) / Get Open Tickets from Salesforce API [Tutorials](http://35.223.47.52/blogs/tutorials/) · August 13, 2026 

Get Open Tickets from Salesforce API
====================================

 ![](https://storage.googleapis.com/knit-website-media/2026/08/64c34ca1e0546a9d333bb35a_Kunal-3-150x150.png)Kunal Mishra

4 min read

 

 

 [](https://www.linkedin.com/sharing/share-offsite/?url=http%3A%2F%2F35.223.47.52%2Fblog%2Fget-open-tickets-from-salesforce-api%2F) [](https://twitter.com/intent/tweet?url=http%3A%2F%2F35.223.47.52%2Fblog%2Fget-open-tickets-from-salesforce-api%2F&text=Get%20Open%20Tickets%20from%20Salesforce%20API)  

 

 

 

  Table of Contents - [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [API Endpoints](#api-endpoints)
- [Step-by-Step Process](#step-by-step-process)
- [1. Authenticate with Salesforce](#1-authenticate-with-salesforce)
- [2. Query Open Tickets for All Customers](#2-query-open-tickets-for-all-customers)
- [3. Query Open Tickets for One Customer](#3-query-open-tickets-for-one-customer)
- [Common Pitfalls](#common-pitfalls)
- [Frequently Asked Questions](#frequently-asked-questions)
- [1. What is the API limit for Salesforce?](#1-what-is-the-api-limit-for-salesforce)
- [2. How do I find my Salesforce instance URL?](#2-how-do-i-find-my-salesforce-instance-url)
- [3. Can I use the API to update ticket statuses?](#3-can-i-use-the-api-to-update-ticket-statuses)
- [4. What happens if my security token changes?](#4-what-happens-if-my-security-token-changes)
- [5. How do I handle API errors?](#5-how-do-i-handle-api-errors)
- [6. Is there a way to test API calls?](#6-is-there-a-way-to-test-api-calls)
- [7. Can I access closed tickets?](#7-can-i-access-closed-tickets)
- [Knit for Salesforce API Integration](#knit-for-salesforce-api-integration)
 
  Introduction
------------

This article is part of a broader series covering the [Salesforce API](/blog/salesforce-api-directory/) in depth. In this guide, we focus specifically on how to retrieve open tickets (Cases) using the Salesforce API.

If you’re building reporting workflows, customer support dashboards, or syncing ticket data into external systems, accessing open Cases programmatically is essential. This guide walks through prerequisites, authentication, querying open tickets for all customers, querying for a specific customer, common pitfalls, and key FAQs.

For a comprehensive deep dive into CRM API authentication, rate limits, and other use cases, refer to the complete Salesforce guide [here](/blog/full-list-of-knits-crm-api-guides/).

Prerequisites
-------------

Before making API calls, ensure the following:

- Your Salesforce organization is enabled for API access.
- The user has the **“API Enabled”** permission.
- The user has necessary object-level and field-level permissions to access the **Case** object.
- You have the Salesforce API endpoint URL and authentication credentials: 
    - Client ID
    - Client Secret
    - Username
    - Password
    - Security Token

API Endpoints
-------------

- **Authentication Endpoint**
    `https://login.salesforce.com/services/oauth2/token`
- **Query Cases Endpoint**
    `https://yourInstance.salesforce.com/services/data/vXX.X/query/`

Replace `vXX.X` with the API version you are using.

Step-by-Step Process
--------------------

### 1. Authenticate with Salesforce

```
import requests

def authenticate(client_id, client_secret, username, password, security_token):
    url = 'https://login.salesforce.com/services/oauth2/token'
    payload = {
        'grant_type': 'password',
        'client_id': client_id,
        'client_secret': client_secret,
        'username': username,
        'password': password + security_token
    }

    response = requests.post(url, data=payload)

    if response.status_code == 200:
        return response.json()['access_token'], response.json()['instance_url']
    else:
        raise Exception('Authentication failed: ' + response.text)
```

This function returns:

- `access_token` – required for authorized API calls
- `instance_url` – your Salesforce instance-specific base URL

### 2. Query Open Tickets for All Customers

```
def get_open_tickets(access_token, instance_url):
    query = "SELECT Id, Subject, Status FROM Case WHERE Status = 'Open'"
    
    headers = {
        'Authorization': 'Bearer ' + access_token
    }
    
    url = instance_url + '/services/data/vXX.X/query/'
    params = {'q': query}

    response = requests.get(url, headers=headers, params=params)

    if response.status_code == 200:
        return response.json()['records']
    else:
        raise Exception('Query failed: ' + response.text)
```

This retrieves all Cases where the status is **Open**.

### 3. Query Open Tickets for One Customer

```
def get_open_tickets_for_customer(access_token, instance_url, customer_id):
    query = f"SELECT Id, Subject, Status FROM Case WHERE Status = 'Open' AND AccountId = '{customer_id}'"
    
    headers = {
        'Authorization': 'Bearer ' + access_token
    }
    
    url = instance_url + '/services/data/vXX.X/query/'
    params = {'q': query}

    response = requests.get(url, headers=headers, params=params)

    if response.status_code == 200:
        return response.json()['records']
    else:
        raise Exception('Query failed: ' + response.text)
```

This filters open Cases for a specific `AccountId`.

Common Pitfalls
---------------

When integrating with the Salesforce API to retrieve open tickets, teams often run into avoidable issues. Watch out for the following:

1. **Incorrect API endpoint URL** – Using the wrong instance URL or incorrect API version.
2. **Invalid authentication credentials** – Incorrect client credentials, password, or missing security token.
3. **Insufficient user permissions** – Lack of access to the Case object or required fields.
4. **Incorrect SOQL syntax** – Small query errors can result in failed requests.
5. **API version mismatch** – Using deprecated or unsupported API versions.
6. **Rate limits exceeded** – Salesforce enforces API limits based on edition and license type.
7. **Network connectivity issues** – Timeouts or firewall restrictions can disrupt requests.

Proactively validating credentials, permissions, and API versions significantly reduces integration failures.

Frequently Asked Questions
--------------------------

### 1. What is the API limit for Salesforce?

Salesforce imposes limits based on the edition and license type of your organization.

### 2. How do I find my Salesforce instance URL?

It is returned in the authentication response after a successful login.

### 3. Can I use the API to update ticket statuses?

Yes, provided the user has appropriate permissions to update Case records.

### 4. What happens if my security token changes?

You must update your application with the new security token.

### 5. How do I handle API errors?

Check the response status code and inspect the error message returned in the response body.

### 6. Is there a way to test API calls?

Yes. Tools such as Postman can be used to test authentication and query endpoints.

### 7. Can I access closed tickets?

Yes. Modify the SOQL query to include closed statuses or remove the status filter.

Knit for Salesforce API Integration
-----------------------------------

For quick and seamless access to the [Salesforce API](/integration/salesforce-api/), Knit API offers a convenient solution. By integrating with Knit once, you can streamline the entire process. Knit handles authentication, authorization, and ongoing integration maintenance.

This approach reduces engineering overhead, saves implementation time, and ensures a reliable connection to Salesforce without managing API complexity directly.

‍

---

**Ready to build this integration?**
Explore Knit’s [Salesforce API integration](/integration/salesforce-api/) or read more about our [Unified CRM API](/integration-categories/unified-crm-api/).

 

 ![](https://storage.googleapis.com/knit-website-media/2026/08/64c34ca1e0546a9d333bb35a_Kunal-3-150x150.png)Written by Kunal Mishra

Changing integration landscape, one organization at a time‍

 

 

 

 

 

   Keep Reading
------------

  ![](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-red-scaled-640x400.png) [API Directory](http://35.223.47.52/blogs/api-directory/) 

### [Salesforce API Directory](http://35.223.47.52/blog/salesforce-api-directory/)

Learn about all Salesforce REST API endpoints to start building your first Salesforce API Integration.

 August 13, 2026 · 6 min read 

 

   ![](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-yellow-scaled-640x400.png) [Tutorials](http://35.223.47.52/blogs/tutorials/) 

### [Salesforce API Integration Guide In-Depth (2026)](http://35.223.47.52/blog/salesforce-api-integration-in-depth/)

Learn how Salesforce API integration works, which of the 7 Salesforce APIs to use, and how to authenticate, query data,…

 June 20, 2026 · 28 min read 

 

   ![](https://storage.googleapis.com/knit-website-media/2026/08/blog-banner-green-640x400.png) [Developers](http://35.223.47.52/blogs/developers/) 

### [How to Get a Salesforce API Key (Connected App)](http://35.223.47.52/blog/salesforce-api-key/)

Create a Salesforce Connected App, get your Consumer Key and Secret, and use OAuth 2.0 to call the Salesforce REST…

 June 20, 2026 · 9 min read 

 

  

 

  \#1 in Ease of Integrations
---------------------------

![4.9 out of 5 stars](/wp-content/themes/knit/assets/images/g2/g2-star-rating.svg)

4.9 out of 5 stars on G2

![G2 Leader, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-leader.svg)![G2 Fastest Implementation, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-fastest-implementation.svg)![G2 High Performer, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-high-performer.svg)![G2 Best Est. ROI, Spring 2026](/wp-content/themes/knit/assets/images/g2/g2-best-roi.svg)

 

  Put Integrations on Autopilot. Talk to Experts.
-----------------------------------------------

Knit is loved by customers across the globe due to our seamless product and white glove support. You'll love us too!

 [Talk to a Human](/book-demo)
