Execute CRM Query
curl --request POST \
--url https://api.attention.tech/v2/crm/query \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"query": "SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10"
}
EOFimport requests
url = "https://api.attention.tech/v2/crm/query"
payload = { "query": "SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'SELECT Id, Name, Amount FROM Opportunity WHERE StageName = \'Closed Won\' LIMIT 10'
})
};
fetch('https://api.attention.tech/v2/crm/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.attention.tech/v2/crm/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => 'SELECT Id, Name, Amount FROM Opportunity WHERE StageName = \'Closed Won\' LIMIT 10'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.attention.tech/v2/crm/query"
payload := strings.NewReader("{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.attention.tech/v2/crm/query")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.attention.tech/v2/crm/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}"
response = http.request(request)
puts response.read_body{
"records": [
{
"Id": "006ABC123",
"Name": "Enterprise Deal",
"Amount": 50000
}
],
"totalSize": 1,
"done": true
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"code": 401,
"message": "unauthenticated for Invalid API key"
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}CRM
Execute CRM Query
Executes a query against the connected CRM platform (e.g., Salesforce SOQL). The query is validated for security before execution.
POST
/
crm
/
query
Execute CRM Query
curl --request POST \
--url https://api.attention.tech/v2/crm/query \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data @- <<EOF
{
"query": "SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10"
}
EOFimport requests
url = "https://api.attention.tech/v2/crm/query"
payload = { "query": "SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10" }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: 'SELECT Id, Name, Amount FROM Opportunity WHERE StageName = \'Closed Won\' LIMIT 10'
})
};
fetch('https://api.attention.tech/v2/crm/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.attention.tech/v2/crm/query",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => 'SELECT Id, Name, Amount FROM Opportunity WHERE StageName = \'Closed Won\' LIMIT 10'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.attention.tech/v2/crm/query"
payload := strings.NewReader("{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.attention.tech/v2/crm/query")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.attention.tech/v2/crm/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won' LIMIT 10\"\n}"
response = http.request(request)
puts response.read_body{
"records": [
{
"Id": "006ABC123",
"Name": "Enterprise Deal",
"Amount": 50000
}
],
"totalSize": 1,
"done": true
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"code": 401,
"message": "unauthenticated for Invalid API key"
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}{
"id": "not_found_error",
"status": "404",
"code": "404",
"title": "Not Found Error",
"detail": "The requested resource was not found",
"source": {
"pointer": "/data/attributes/id"
}
}Authorizations
Body
application/json
Query request payload
The query to execute (e.g., SOQL for Salesforce)
Maximum string length:
10000Example:
"SELECT Id, Name, Email FROM Contact WHERE CreatedDate = LAST_N_DAYS:30 LIMIT 100"
Was this page helpful?
⌘I