Create a target
POST
/api/v1/targets
using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://external-api.moja-ai.com/api/v1/targets"), Headers = { { "X-API-Key", "<X-API-Key>" }, }, Content = new StringContent("{ \"name\": \"example\", \"buyer_id\": \"example\", \"type\": \"number\", \"number\": \"example\", \"sip_endpoint\": \"example\", \"sip_username\": \"example\", \"sip_password\": \"example\", \"sip_headers\": { \"X-Campaign\": \"sales\", \"X-Trace-Id\": \"trace-123\" }, \"connection_timeout\": 1, \"timezone\": \"America/New_York\", \"is_active\": false, \"max_concurrency\": 1, \"revenue\": 1, \"payout\": 1, \"payout_condition\": \"call_successfully_connected\", \"payout_condition_duration\": 1, \"conversion_scope\": 10, \"duplicate_conversion_action\": \"decline\", \"consider_duplicate\": false, \"consider_duplicate_on\": \"example\", \"consider_duplicate_length\": 1, \"consider_duplicate_interval\": 30, \"disable_recordings\": false, \"access_to_call_recordings\": true, \"filters\": { \"enabled\": true, \"groups\": [ { \"conditions\": [ { \"field\": \"state\", \"operator\": \"in\", \"values\": [ \"CA\", \"TX\" ] } ] } ] }, \"hours_of_operation\": { \"always_open\": false, \"days\": [ { \"day\": \"monday\", \"hours\": \"custom\", \"isOpen\": true, \"timeRanges\": [ { \"end\": \"17:00\", \"start\": \"09:00\" } ] } ] }, \"external_id\": \"example\", \"advanced_caps\": [ {} ] }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://external-api.moja-ai.com/api/v1/targets"
payload := strings.NewReader("{ \"name\": \"example\", \"buyer_id\": \"example\", \"type\": \"number\", \"number\": \"example\", \"sip_endpoint\": \"example\", \"sip_username\": \"example\", \"sip_password\": \"example\", \"sip_headers\": { \"X-Campaign\": \"sales\", \"X-Trace-Id\": \"trace-123\" }, \"connection_timeout\": 1, \"timezone\": \"America/New_York\", \"is_active\": false, \"max_concurrency\": 1, \"revenue\": 1, \"payout\": 1, \"payout_condition\": \"call_successfully_connected\", \"payout_condition_duration\": 1, \"conversion_scope\": 10, \"duplicate_conversion_action\": \"decline\", \"consider_duplicate\": false, \"consider_duplicate_on\": \"example\", \"consider_duplicate_length\": 1, \"consider_duplicate_interval\": 30, \"disable_recordings\": false, \"access_to_call_recordings\": true, \"filters\": { \"enabled\": true, \"groups\": [ { \"conditions\": [ { \"field\": \"state\", \"operator\": \"in\", \"values\": [ \"CA\", \"TX\" ] } ] } ] }, \"hours_of_operation\": { \"always_open\": false, \"days\": [ { \"day\": \"monday\", \"hours\": \"custom\", \"isOpen\": true, \"timeRanges\": [ { \"end\": \"17:00\", \"start\": \"09:00\" } ] } ] }, \"external_id\": \"example\", \"advanced_caps\": [ {} ] }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<X-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(res) fmt.Println(string(body))
}const url = 'https://external-api.moja-ai.com/api/v1/targets';const options = { method: 'POST', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"name":"example","buyer_id":"example","type":"number","number":"example","sip_endpoint":"example","sip_username":"example","sip_password":"example","sip_headers":{"X-Campaign":"sales","X-Trace-Id":"trace-123"},"connection_timeout":1,"timezone":"America/New_York","is_active":false,"max_concurrency":1,"revenue":1,"payout":1,"payout_condition":"call_successfully_connected","payout_condition_duration":1,"conversion_scope":10,"duplicate_conversion_action":"decline","consider_duplicate":false,"consider_duplicate_on":"example","consider_duplicate_length":1,"consider_duplicate_interval":30,"disable_recordings":false,"access_to_call_recordings":true,"filters":{"enabled":true,"groups":[{"conditions":[{"field":"state","operator":"in","values":["CA","TX"]}]}]},"hours_of_operation":{"always_open":false,"days":[{"day":"monday","hours":"custom","isOpen":true,"timeRanges":[{"end":"17:00","start":"09:00"}]}]},"external_id":"example","advanced_caps":[{}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://external-api.moja-ai.com/api/v1/targets \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "name": "example", "buyer_id": "example", "type": "number", "number": "example", "sip_endpoint": "example", "sip_username": "example", "sip_password": "example", "sip_headers": { "X-Campaign": "sales", "X-Trace-Id": "trace-123" }, "connection_timeout": 1, "timezone": "America/New_York", "is_active": false, "max_concurrency": 1, "revenue": 1, "payout": 1, "payout_condition": "call_successfully_connected", "payout_condition_duration": 1, "conversion_scope": 10, "duplicate_conversion_action": "decline", "consider_duplicate": false, "consider_duplicate_on": "example", "consider_duplicate_length": 1, "consider_duplicate_interval": 30, "disable_recordings": false, "access_to_call_recordings": true, "filters": { "enabled": true, "groups": [ { "conditions": [ { "field": "state", "operator": "in", "values": [ "CA", "TX" ] } ] } ] }, "hours_of_operation": { "always_open": false, "days": [ { "day": "monday", "hours": "custom", "isOpen": true, "timeRanges": [ { "end": "17:00", "start": "09:00" } ] } ] }, "external_id": "example", "advanced_caps": [ {} ] }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
TargetCreate
object
name
required
Name
string
buyer_id
required
Buyer Id
string
type
required
Type
string
timezone
Timezone
string
is_active
Is Active
boolean
payout_condition
Payout Condition
string
conversion_scope
Conversion Scope
integer
duplicate_conversion_action
Duplicate Conversion Action
string
consider_duplicate
Consider Duplicate
boolean
consider_duplicate_interval
Consider Duplicate Interval
Lookback window in days for the consider-duplicate check
integer
disable_recordings
Disable Recordings
boolean
advanced_caps
Any of:
Array<object>
object
key
additional properties
any
null
Responses
Section titled “Responses”Successful Response
Media typeapplication/json
TargetResponse
object
id
required
Id
string
name
required
Name
string
org_id
required
Org Id
string
timezone
Timezone
string
is_active
required
Is Active
boolean
conversion_scope
required
Conversion Scope
integer
duplicate_conversion_action
Duplicate Conversion Action
string
consider_duplicate
Consider Duplicate
boolean
consider_duplicate_interval
Consider Duplicate Interval
integer
disable_recordings
Disable Recordings
boolean
access_to_call_recordings
required
Access To Call Recordings
boolean
advanced_caps
Advanced Caps
Array<object>
object
key
additional properties
any
is_paused
Is Paused
boolean
Example
{ "sip_headers": { "X-Campaign": "sales", "X-Trace-Id": "trace-123" }, "timezone": "America/New_York", "duplicate_conversion_action": "decline", "consider_duplicate": false, "consider_duplicate_interval": 30, "disable_recordings": false, "filters": { "enabled": true, "groups": [ { "conditions": [ { "field": "state", "operator": "in", "values": [ "CA", "TX" ] } ] } ] }, "hours_of_operation": { "always_open": false, "days": [ { "day": "monday", "hours": "custom", "isOpen": true, "timeRanges": [ { "end": "17:00", "start": "09:00" } ] } ] }, "is_paused": false}Bad Request
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Unauthorized
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Not Found
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Conflict
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}Validation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{ "detail": [ { "loc": [ "example" ], "msg": "example", "type": "example", "input": "example", "ctx": {} } ]}Too Many Requests
Media typeapplication/json
ErrorResponse
object
detail
required
ErrorBody
object
code
required
Code
string
message
required
Message
string
Examplegenerated
{ "detail": { "code": "example", "message": "example" }}
