curl --request POST \
--url https://api.affinity.co/v2/opportunities \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"isRestricted": false
}
'import requests
url = "https://api.affinity.co/v2/opportunities"
payload = {
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"isRestricted": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Horizon Technologies Upsell $10k', listId: 1, isRestricted: false})
};
fetch('https://api.affinity.co/v2/opportunities', 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.affinity.co/v2/opportunities",
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([
'name' => 'Horizon Technologies Upsell $10k',
'listId' => 1,
'isRestricted' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.affinity.co/v2/opportunities"
payload := strings.NewReader("{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.affinity.co/v2/opportunities")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/opportunities")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"listName": "Pipeline Q1 2024",
"isRestricted": false,
"isRedacted": false
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Create an Opportunity
| This endpoint is currently in BETA |
|---|
Creates an Opportunity on an opportunity List. The Opportunity is added to the List as a List Entry. When listId is not an opportunity List, the request fails.
The new List Entry gets the default values of the List. When the List has a Status Field, the Status is the first open status. When the List has an Owners Field, the requester is added as an Owner.
The name must be unique on the List. The request cannot include Field values, so the required Fields of the List are not checked.
When isRestricted is true, the Opportunity is restricted, and the requester is added to its allow list. When a Person Field of the List sets the allow list, the requester is added to that Field. When the requester cannot access the new Opportunity, the response is redacted.
When your organization does not allow the requested type of Opportunity, the request fails.
Requires access to the List.
curl --request POST \
--url https://api.affinity.co/v2/opportunities \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"isRestricted": false
}
'import requests
url = "https://api.affinity.co/v2/opportunities"
payload = {
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"isRestricted": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Horizon Technologies Upsell $10k', listId: 1, isRestricted: false})
};
fetch('https://api.affinity.co/v2/opportunities', 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.affinity.co/v2/opportunities",
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([
'name' => 'Horizon Technologies Upsell $10k',
'listId' => 1,
'isRestricted' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.affinity.co/v2/opportunities"
payload := strings.NewReader("{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.affinity.co/v2/opportunities")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/opportunities")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Horizon Technologies Upsell $10k\",\n \"listId\": 1,\n \"isRestricted\": false\n}"
response = http.request(request)
puts response.read_body{
"id": 1,
"name": "Horizon Technologies Upsell $10k",
"listId": 1,
"listName": "Pipeline Q1 2024",
"isRestricted": false,
"isRedacted": false
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Authorizations
Body
Request body to create an Opportunity.
Response
Created
Opportunity model.
Was this page helpful?