API Reference


The Targg API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

The Targg API differs for every account as we release new versions and tailor functionality. These docs are customized to your version of the API and display your test key and test data, which only you can see.

With our API you can make calls to any phone number.

It is good to emphasize that you should use our API together with your administrative system, since variables will be used that will only be provided through it, for example: template ID.

BASE URL
https://api.targg.com
Need help?
If you need any help, send an email to [email protected]
We will answer as soon as possible

Authentication


The Targg API uses API keys to authenticate requests. You can view and manage your API keys in the Targg Api Keys.

Your API key carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.

Authentication to the API is performed via HTTP Bearer Auth. Provide your API key as the basic auth username value. You do not need to provide a password.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

SAMPLE CURL REQUEST
curl https://api.targg.com/v1/contacts \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
# The colon prevents curl from asking for a password.
Where i could find the token?
It's Simple, Signin into our website and Click here!

Errors


Targg uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a phone call failed, etc.). Codes in the 5xx range indicate an error with Targg's servers (these are rare).

Some 4xx errors that could be handled programmatically (e.g., a invalid phone number) include an error code that briefly explains the error reported.

Attributes

response Bool
The response from api, if true means it worked, if false means it gave error.

message String
Message is the message that was returned from an error by the API.

HTTP STATUS CODES
200 (OK)
Everything is working correctly!
400 (Bad Request)
The request was unacceptable, often due to missing a required parameter.
401 (Unauthorized)
No valid API Token provided.
404 (Not Found)
The requested resource doesn't exist.
429 (Too Many Requests)
Too many requests hit the API too quickly. We recommend an exponential backoff of your requests.
500, 502, 503, 504 (Server Errors)
Something went wrong on Targg's end. (These are rare)

Credits


The Targg API provides control over your account credits. With this feature, you can check if there are any credits left for you to use, or if any of your campaigns are running out of credit limits.

It is important to remember that if you are running out of credits you must enable automatic credit renewal. Just go to your administrative area and activate the feature, thus avoiding suspension of service.

If you are using our whitelabel service, with the service to view the amount spent per campaign you can control your customers in a much more transparent way, preventing one of them from using more resources than was agreed.

Remaining Credits


Retrieves the current account balance, based on the authentication that was used to make the request.

Arguments

No arguments.


Returns

Returns a balance object for the account that was authenticated in the request.
GET /v1/remaining_credits/
curl https://api.targg.com/v1/remaining_credits \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "balance": {
        "_id": "5e593a35124dads9b5",
        "value": 10,
        "currency": "R$",
        "automatic_recharge": false,
        "company": "5e593a357bfafsf24248e",
        "external_customer_id": "cus_Goo2rrQ69xC",
        "createdAt": "2020-02-28T16:05:09.948Z",
        "updatedAt": "2020-02-28T16:05:09.948Z",
        "__v": 0
    }
}

Used credits per campaign


Returns used credits per campaign, and allows you to make specific filters.

Arguments

campaigns Array of String (optional)
Array of ids of campaigns. (e.g., ["id1", "id2", "id3"]).

ini_date Date (optional)
Filter of initial date (e.g., 2020-01-01).

end_date Date (optional)
Filter of End date (e.g., 2020-01-01).



Returns

Returns the comparing of cost per campaign.
GET /v1/use_per_campaign/
curl https://api.targg.com/v1/use_per_campaign?ini_date=2019-01-10&end_date=2021-01-11 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "results": [
        {
            "_id": "824u82424djsdj2",
            "totalAmount": 0.5
        }
    ]
}

Templates


The Targg API permits you to view all your templates, to use later in calls and campaigns.

To create a template, you can access the following link.

ENDPOINTS
TEMPLATE OBJECT
{
  "phone_test_inbound": [],
  "_id": "5e4ac1c86c592asdd400175ac279",
  "name": "E-commerce",
  "objective": "objective9",
  "category": "category4",
  "is_public": true,
  "template_base": null,
  "language": "pt-br",
  "type": "outbound",
  "forks_number": 0,
  "company": "5e593a357bdssd24f99d004389b48e",
  "description": "Vendas, abandono de carrinho.",
  "priority": 0,
  "createdAt": "2020-02-17T16:39:36.808Z",
  "updatedAt": "2020-02-17T16:39:36.808Z",
  "__v": 0
}

Get all templates


Retrieves all your templates paginated.

Arguments

limit Integer (optional)
Maximum number of templates to bring per page, default = 10, maximum = 50.

page Integer (required)
the current page.


Returns

Returns the templates objects paginated.
GET /v1/templates
curl https://api.targg.com/v1/templates?limit=15&page=1 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "templates": {
        "docs": [
            {
                "phone_test_inbound": [],
                "_id": "5e4ac1c86c592asdd400175ac279",
                "name": "E-commerce",
                "objective": "objective9",
                "category": "category4",
                "is_public": true,
                "template_base": null,
                "language": "pt-br",
                "type": "outbound",
                "forks_number": 0,
                "company": "5e593a357bdssd24f99d004389b48e",
                "description": "Vendas, abandono de carrinho.",
                "priority": 0,
                "createdAt": "2020-02-17T16:39:36.808Z",
                "updatedAt": "2020-02-17T16:39:36.808Z",
                "__v": 0
            }
        ],
        "totalDocs": 1,
        "limit": 10,
        "offset": 0
    }
}

Get template details


Retrieves all details of a specific template.

Arguments

No arguments.


Returns

Return the template object.
GET /v1/template/:id
curl https://api.targg.com/v1/template/4245erfasffas245562ucjgxs \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "template": {
        "phone_test_inbound": [],
        "_id": "5e4ac1c86c59sdds2400175ac279",
        "name": "E-commerce",
        "objective": "objective9",
        "category": "category4",
        "is_public": true,
        "template_base": null,
        "language": "pt-br",
        "type": "outbound",
        "forks_number": 0,
        "company": "5e593a357bf99dsds004389b48e",
        "description": "Vendas, abandono de carrinho.",
        "priority": 0,
        "createdAt": "2020-02-17T16:39:36.808Z",
        "updatedAt": "2020-02-17T16:39:36.808Z",
        "__v": 0
    }
}

Campaigns


The Targg API permits you to created, edit, remove or delete all yours campaigns.

To manage the campaigns manually, you can access the follow link.

CAMPAIGN OBJECT
{
    "tags": [],
    "_id": "5e5c402627d49b2b7468aa12",
    "allDays": [],
    "title": "Campaign 1",
    "status": "paused",
    "templateId": "5e4ac1c86c592400175ac279",
    "company": "5e593a357bf99d004389b48e",
    "internalAudios": null,
    "externalId": "Testx",
    "calls_per_day": 0,
    "has_holiday": false,
    "createdAt": "2020-03-01T23:07:18.072Z",
    "updatedAt": "2020-03-01T23:07:18.072Z",
    "__v": 0
}

Create campaign


Create a programatic campaign.

Arguments

title String (required)
Title of your campaign.

status Enum (required)
Status of your campaign, possible values: active, paused and inactive.

templateId String (required)
Id of template, the template must be for Callbot, not allowed IVR's template.

credits_per_day Float (optional)
Limit calls per credit / day. (e.g., 100.00)
The currency (R$ or US$) will be automatic set, based on the account currency.
Your schedules will be blocked when you reach the limit of credits per day, and will only resume the next day.

tags Array of string (optional)
The tags of your contacts to import them to this campaign. (e.g., ["dentist", "client", "for_campaign1", "gym_client", ...]).

automatic_scheduler Boolean (required)
Automatic schedule will schedule your calls automatic. Every morning our scheduler starts. It will schedule contacts based on the parameters you put in the system, you can check the times scheduled in your campaign.

calls_per_day Integer (optional)
Limit schedules per day. It will work only when automatic_scheduler is true. Default value is 1.

has_holiday Boolean (optional)
Schedule calls to holiday or not. It will work only when automatic_scheduler is true. Default value is false.

allDays Array of objects (optional)
Hours to schedule calls. It will work only when automatic_scheduler is true. Default value is [].

day String (required)
Day of the week. (sunday, monday, tuesday, wednesday, thursday, friday, saturday)

start String (required)
Start time. (e.g., 10:00)

end String (required)
End time. (e.g., 10:00)

timeline_retry Array of objects (optional)
Your custom strategy of retry calls, the order of elements matters!

unit Number (required)
Unit of measure: 1 (hours), 2 (days), 3 (weeks), 4 (months), 5 (years),

duration Number (required)
Number of units to reschedule

option_hour Number (required)
Reschedule in business day or not. 1 (Normal day), 2 (Business day)

phone_choose Number (required)
Reschedule the call to the same phone or another one. 1 (Same phone), 2 (Another phone)

externalId String (optional)
Id of your system, it's only used for your control.


Returns

Returns the campaign object created.
POST /v1/campaign
curl https://api.targg.com/v1/campaign \ 
  -X POST -d '{"title":"Campaign 1", "automatic_scheduler": false, "status":"paused", "templateId": "5e4ac1c86c592400175ac279", "externalId": "Testx"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "campaign": {
        "tags": [],
        "_id": "5e5c402627d49b2b7468aa12",
        "allDays": [],
        "title": "Campaign 1",
        "status": "paused",
        "templateId": "5e4ac1c86c592400175ac279",
        "company": "5e593a357bf99d004389b48e",
        "internalAudios": null,
        "externalId": "Testx",
        "calls_per_day": 0,
        "has_holiday": false,
        "createdAt": "2020-03-01T23:07:18.072Z",
        "updatedAt": "2020-03-01T23:07:18.072Z",
        "__v": 0
    }
}

Get all campaigns


Retrieves all your campaigns paginated.

Arguments

limit Integer (optional)
Maximum number of campaigns to bring per page, default = 10, maximum = 50.

page Integer (required)
the current page.

title String (optional)
Search for campaign title.

showDeleted Bool (optional)
Show campaigns deleted. Default is true.

orderBy Enum (optional)
Order results. Possible values are title, calls or status. Default is title.


Returns

Returns the campaigns objects paginated.
GET /v1/campaigns
curl https://api.targg.com/v1/campaigns?limit=15&page=1 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "campaigns": {
        "docs": [
            {
                "tags": [],
                "_id": "5e5c3faa27d49b2b7468aa11",
                "allDays": [],
                "title": "Campaign 1",
                "status": "active",
                "templateId": "5e4ac1c86c592400175ac279",
                "company": "5e593a357bf99d004389b48e",
                "internalAudios": null,
                "externalId": "Testx",
                "calls_per_day": 0,
                "has_holiday": false,
                "createdAt": "2020-03-01T23:05:14.815Z",
                "updatedAt": "2020-03-01T23:05:14.815Z",
                "__v": 0
            }
        ],
        "totalDocs": 1,
        "limit": 10,
        "offset": 0
    }
}

Get campaign details


Retrieves all details of a specific campaign.

Arguments

No arguments.


Returns

Return the campaign object.
GET /v1/campaign/:id
curl https://api.targg.com/v1/campaign/4245erfasffas245562ucjgxs \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "campaign": {
        "tags": [],
        "_id": "5e5c3faa27d49b2b7468aa11",
        "allDays": [],
        "title": "Campaign 1",
        "status": "active",
        "templateId": "5e4ac1c86c592400175ac279",
        "company": "5e593a357bf99d004389b48e",
        "internalAudios": null,
        "externalId": "Testx",
        "calls_per_day": 0,
        "has_holiday": false,
        "createdAt": "2020-03-01T23:05:14.815Z",
        "updatedAt": "2020-03-01T23:05:14.815Z",
        "__v": 0
    }
}

Update campaign


Update a programatic campaign.

Arguments

title String (required)
Title of your campaign.

status Enum (required)
Status of your campaign, possible values: active, paused and inactive.

templateId String (required)
Id of template, the template must be for Callbot, not allowed IVR's template.

credits_per_day Float (optional)
Limit calls per credit / day. (e.g., 100.00)
The currency (R$ or US$) will be automatic set, based on the account currency.
Your schedules will be blocked when you reach the limit of credits per day, and will only resume the next day.

tags Array of string (optional)
The tags of your contacts to import them to this campaign. (e.g., ["dentist", "client", "for_campaign1", "gym_client", ...]).

automatic_scheduler Boolean (required)
Automatic schedule will schedule your calls automatic. Every morning our scheduler starts. It will schedule contacts based on the parameters you put in the system, you can check the times scheduled in your campaign.

calls_per_day Integer (optional)
Limit schedules per day. It will work only when automatic_scheduler is true. Default value is 1.

has_holiday Boolean (optional)
Schedule calls to holiday or not. It will work only when automatic_scheduler is true. Default value is false.

allDays Array of objects (optional)
Hours to schedule calls. It will work only when automatic_scheduler is true. Default value is [].

day String (required)
Day of the week. (sunday, monday, tuesday, wednesday, thursday, friday, saturday)

start String (required)
Start time. (e.g., 10:00)

end String (required)
End time. (e.g., 10:00)

timeline_retry Array of objects (optional)
Your custom strategy of retry calls, the order of elements matters!

unit Number (required)
Unit of measure: 1 (hours), 2 (days), 3 (weeks), 4 (months), 5 (years),

duration Number (required)
Number of units to reschedule

option_hour Number (required)
Reschedule in business day or not. 1 (Normal day), 2 (Business day)

phone_choose Number (required)
Reschedule the call to the same phone or another one. 1 (Same phone), 2 (Another phone)

externalId String (optional)
Id of your system, it's only used for your control.


Returns

Return if the operations was succesfully or not.
PUT /v1/campaign/:id
curl https://api.targg.com/v1/campaign/ijf83t9020i2jffDJhp \ 
  -X PUT -d '{"title":"some Title", "automatic_scheduler": false, "status":"active", "templateId": "jf45454f920025502açsdçaDJk2", "externalId": "9245"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
  "response": true
}

Delete campaign


Delete a programatic campaign.

Arguments
No arguments.


Returns

Returns a message warning if the deletion was completed.
DELETE /v1/campaign/:id
curl https://api.targg.com/v1/campaign/ijf83t9020i2jffDJhp \ 
  -X DELETE -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true
}

Contacts


The Targg API permits you to created, edit, remove or delete all yours contacts.

To manage the contacts manually, you can access the following link.

CONTACT OBJECT
{
    "blockedCampaigns": [],
    "tags": [],
    "_id": "5e5c4b0abf4a9c18a0eb1f7e",
    "phones": [
        {
            "_id": "5e5c4b0abf4a9c18a0eb1f7f",
            "number": "5519988884444",
            "main": true,
            "not_disturb": false,
            "type": "residential"
        }
    ],
    "rescheduleCampaigns": [],
    "aditionalFields": [],
    "name": "Raphael Linz",
    "company": "5e593a357bf99d004389b48e",
    "language": "pt-br",
    "email": "[email protected]",
    "has_aditional_fields": false,
    "status": "active",
    "blacklist": false,
    "createdAt": "2020-03-01T23:53:46.852Z",
    "updatedAt": "2020-03-01T23:53:46.852Z",
    "__v": 0
}

Create contact


Create a contact.

Arguments

name String (optional)
Name of your contact.

email String (optional)
Email of your contact.

phones Array (required)
Array of phones.

number String (required)
Phone number of your contact.
For Brazil the format needs to be 55XXXXXXXXXXX or 55XXXXXXXXXX only numbers. (e.g., 5511999991111)
For United States the format needs to be 1XXXXXXXXXX (e.g., 12015551520)

main Boolean (required)
Boolean to inform if this phone is the main phone.

not_disturb Boolean (required)
Boolean to inform if we can call to this phone. The main phone cant be a not_disturb.

type Enum (required)
Type of the telephone. The possible values are: commercial, residential or other.

contactCompany String (optional)
Company of your contact.

language Enum (required)
Language of your contact. The only values permited are pt-br or en-us.

gender Enum (optional)
Gender of your contact. The only values permited are male or female.

birth_date Date (optional)
Birth date of your contact. (e.g., 1990-01-01).

status Enum (optional)
Status of your contact. The only values permited are active, paused, not_disturb, inactive or deleted. (default: active).

tags Array of strings (optional)
The tags of your contact. (e.g., ["dentist", "client", "for_campaign1", "gym_client", ...]).

has_aditional_fields Bool (optional)
True if you need to add more informations or false if not (default: false).

externalId String (optional)
Id of your system, it's only used for your control.

aditionalFields Array of objects (optional)
Should be passed if has_aditional_fields is true.

key String (required)
Key of your aditional field. (e.g., debit)

type Enum (required)
The type of the aditional fields. The only values permited are text or number.

value String or Float (required)
If the type is number, the number needs to be a Float. (e.g., 1500.00).
Otherwise, the number needs to be a String.


Returns

Returns the contact object created.
POST /v1/contact
curl https://api.targg.com/v1/contact \ 
  -X POST -d '{"name":"Rafael Linz", "phones": ["number": "5519988884444", "main": true, "not_disturb": false, "type": "residential"], "language": "pt-br"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "contact": {
        "blockedCampaigns": [],
        "tags": [],
        "_id": "5e5c4b0abf4a9c18a0eb1f7e",
        "phones": [
            {
                "_id": "5e5c4b0abf4a9c18a0eb1f7f",
                "number": "5519988884444",
                "main": true,
                "not_disturb": false,
                "type": "residential"
            }
        ],
        "rescheduleCampaigns": [],
        "aditionalFields": [],
        "name": "Raphael Linz",
        "company": "5e593a357bf99d004389b48e",
        "language": "pt-br",
        "email": "[email protected]",
        "has_aditional_fields": false,
        "status": "active",
        "blacklist": false,
        "createdAt": "2020-03-01T23:53:46.852Z",
        "updatedAt": "2020-03-01T23:53:46.852Z",
        "__v": 0
    }
}

Get all contacts


Retrieves all your contacts paginated.

Arguments

limit Integer (optional)
Maximum number of contacts to bring per page, default = 10, maximum = 50.

page Integer (required)
the current page.

name String (optional)
search by name.

campaign String (optional)
Campaign ID.

tags Array of Strings (optional)
Array of tags (e.g., ["tag1","tag2"])

orderBy String (optional)
Order by parameter. The possible values are: name or updated_at. The default value is name.


Returns

Returns the contacts objects paginated.
GET /v1/contacts
curl https://api.targg.com/v1/contacts?limit=15&page=1 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "contacts": {
        "docs": [
            {
                "blockedCampaigns": [],
                "tags": [
                    "111",
                    "222"
                ],
                "_id": "5e59c35eea7be900135fc9bd",
                "rescheduleCampaigns": [],
                "aditionalFields": [],
                "name": "Test 1",
                "company": "5e593a357bf99d004389b48e",
                "phone1": "5519999999999",
                "language": "pt-br",
                "phone2": "551932343355",
                "email": "[email protected]",
                "has_aditional_fields": false,
                "status": "active",
                "contactCompany": "",
                "createdAt": "2020-02-29T01:50:22.093Z",
                "updatedAt": "2020-02-29T01:50:22.093Z",
                "__v": 0,
                "phones": []
            },
            {
                "blockedCampaigns": [],
                "tags": [],
                "_id": "5e5c4ab1d6763d3bb0dc272d",
                "phones": [
                    {
                        "_id": "5e5c4ab1d6763d3bb0dc272e",
                        "number": "5519988884444",
                        "main": true,
                        "not_disturb": false
                    }
                ],
                "rescheduleCampaigns": [],
                "aditionalFields": [],
                "name": "Raphael Linz",
                "company": "5e593a357bf99d004389b48e",
                "language": "pt-br",
                "email": "[email protected]",
                "has_aditional_fields": false,
                "status": "active",
                "blacklist": false,
                "createdAt": "2020-03-01T23:52:17.782Z",
                "updatedAt": "2020-03-01T23:52:17.782Z",
                "__v": 0
            },
            {
                "blockedCampaigns": [],
                "tags": [],
                "_id": "5e5c4b0abf4a9c18a0eb1f7e",
                "phones": [
                    {
                        "_id": "5e5c4b0abf4a9c18a0eb1f7f",
                        "number": "5519988884444",
                        "main": true,
                        "not_disturb": false
                    }
                ],
                "rescheduleCampaigns": [],
                "aditionalFields": [],
                "name": "Raphael Linz",
                "company": "5e593a357bf99d004389b48e",
                "language": "pt-br",
                "email": "[email protected]",
                "has_aditional_fields": false,
                "status": "active",
                "blacklist": false,
                "createdAt": "2020-03-01T23:53:46.852Z",
                "updatedAt": "2020-03-01T23:53:46.852Z",
                "__v": 0
            }
        ],
        "totalDocs": 3,
        "limit": 10,
        "offset": 0
    }
}

Get contact details


Retrieves all details of a specific contact.

Arguments

No arguments.


Returns

Return the contact object.
GET /v1/contact/:id
curl https://api.targg.com/v1/contact/5e5c4b0abf4a9c18a0eb1f7e \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "contact": {
        "blockedCampaigns": [],
        "tags": [],
        "_id": "5e5c4b0abf4a9c18a0eb1f7e",
        "phones": [
            {
                "_id": "5e5c4b0abf4a9c18a0eb1f7f",
                "number": "5519988884444",
                "main": true,
                "not_disturb": false
            }
        ],
        "rescheduleCampaigns": [],
        "aditionalFields": [],
        "name": "Raphael Linz",
        "company": "5e593a357bf99d004389b48e",
        "language": "pt-br",
        "email": "[email protected]",
        "has_aditional_fields": false,
        "status": "active",
        "blacklist": false,
        "createdAt": "2020-03-01T23:53:46.852Z",
        "updatedAt": "2020-03-01T23:53:46.852Z",
        "__v": 0
    }
}

Update contact


Update a contact.

Arguments

name String (optional)
Name of your contact.

email String (optional)
Email of your contact.

phones Array (required)
Array of phones.

number String (required)
Phone number of your contact.
For Brazil the format needs to be 55XXXXXXXXXXX or 55XXXXXXXXXX only numbers. (e.g., 5511999991111)
For United States the format needs to be 1XXXXXXXXXX (e.g., 12015551520)

main Boolean (required)
Boolean to inform if this phone is the main phone.

not_disturb Boolean (required)
Boolean to inform if we can call to this phone. The main phone cant be a not_disturb.

type Enum (required)
Type of the telephone. The possible values are: commercial, residential or other.

contactCompany String (optional)
Company of your contact.

language Enum (required)
Language of your contact. The only values permited are pt-br or en-us.

gender Enum (optional)
Gender of your contact. The only values permited are male or female.

birth_date Date (optional)
Birth date of your contact. (e.g., 1990-01-01).

status Enum (optional)
Status of your contact. The only values permited are active, paused, not_disturb, inactive or deleted. (default: active).

tags Array of strings (optional)
The tags of your contact. (e.g., ["dentist", "client", "for_campaign1", "gym_client", ...]).

has_aditional_fields Bool (optional)
True if you need to add more informations or false if not (default: false).

externalId String (optional)
Id of your system, it's only used for your control.

aditionalFields Array of objects (optional)
Should be passed if has_aditional_fields is true.

key String (required)
Key of your aditional field. (e.g., debit)

type Enum (required)
The type of the aditional fields. The only values permited are text or number.

value String or Float (required)
If the type is number, the number needs to be a Float. (e.g., 1500.00).
Otherwise, the number needs to be a String.


Returns

Return if the operations was succesfully or not.
PUT /v1/contact/:id
curl https://api.targg.com/v1/contact/ijf83t9020i2jffDJhp \ 
  -X PUT -d '{"name":"John", "status":"active", "externalId": "9245"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true
}

Delete contact


Delete a contact.

Arguments
No arguments.


Returns

Returns a message warning if the deletion was completed.
DELETE /v1/contact/:id
curl https://api.targg.com/v1/contact/ijf83t9020i2jffDJhp \ 
  -X DELETE -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true
}

Calls


The Targg API permits you to created, edit, remove or delete all yours calls.

It is important to remember that there are two types of calls, programmatic call and manual call. With this API you will only be able to manage programmatic calls.

To manage the calls manually, you can access the following link.

Calls have few status of calls, they are: scheduled, schedule_done, failed, started, hanged and finished.

- scheduled: It's a call scheduled, not done yet.
- schedule_done: It's a call that was executed, status right after leaving the schedule.
- failed: It's a call that wasn't executed for any reason other than the lack of parameters. (e.g., PO Box, out of area, etc...)
- hanged: It's the status when the customer answers the phone.
- finished: It's the status when the call is successful. You can find the price and other details of calls in this status.

CALL OBJECT
{
    "_id": "5e5c635cf9fba3141889d981",
    "userId": "5e5c59083b76bf0040940602",
    "company": "5e5c59083b76bf0040940602",
    "toNumber": "5519996042828",
    "campaign": "5e5c402627d49b2b7468aa12",
    "environment": "production",
    "inbound_outbound": "outbound",
    "contact": "5e5c4ab1d6763d3bb0dc272d",
    "contactSent": "5e5c4ab1d6763d3bb0dc272d",
    "templateId": "5e4ac1c86c592400175ac279",
    "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNvbnRhdG9AdGFyZ2cuY29tIiwiX2lkIjoiNWU1YzU5MDgzYjc2YmYwMDQwOTQwNjAyIiwiY29tcGFueSI6IjVlNWM1OTA4M2I3NmJmMDA0MDk0MDYwMiIsImNvdW50cnkiOiJicmF6aWwiLCJhcGkiOnRydWUsImlhdCI6MTU4MzExMDQwOH0._gdoGO0XpxQ3_USe1jCd3BOPNRwOJvMpvUd0apw_mzs",
    "respFinal": [],
    "internalAudios": {},
    "audiosFinalToPlay": {},
    "templateFinal": {
        "_id": "5e4ac1c86c592400175ac279",
        "phone_test_inbound": [],
        "name": "E-commerce",
        "objective": "objective9",
        "category": "category4",
        "is_public": true,
        "template_base": null,
        "language": "pt-br",
        "type": "outbound",
        "forks_number": 0,
        "company": "5e5c59083b76bf0040940602",
        "description": "Vendas, abandono de carrinho.",
        "priority": 0,
        "createdAt": "2020-02-17T16:39:36.808Z",
        "updatedAt": "2020-02-17T16:39:36.808Z",
        "__v": 0
    },
    "endpointAsterisk": "SIP/from-pstn5/",
    "balance": [],
    "externalId": null,
    "id_custom": "5519996042828_1583113032",
    "call_uuid": "6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2",
    "status": "finished",
    "timestamp": 1583113063,
    "fullConversation": [],
    "audios": {
        "url": "https://s3-sa-east-1.amazonaws.com/targg-robot-upload-audios/records/maehmtuxjn_6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2.wav",
        "duration": 9.88225
    }
}

Create call


Create a programatic call.

Arguments

contactId String (optional)
id of a contact.

fullContact Object (optional)
Contact parameters using the object of the create endpoint.

campaignId String (optional)
id of a campaign.

fullCampaign Object (optional)
Campaign parameters using the object of the create endpoint.

date Datetime (optional)
The date to schedule a call, the schedule will happen at the hour informed in the timezone of the client (based on phone number), if its not informed, the call will be performed now. (e.g., 2020-01-01 10:00:00)

PAY ATENCION: Its important to take care scheduling hours to prevent call in inopportune times.

externalId String (optional)
Id of your system, it's only used for your control.


Returns

Returns the confirmation that call is created.
POST /v1/call
curl https://api.targg.com/v1/call \ 
  -X POST -d '{"contactId":"24242452fsasfstt24", "campaignId": "jf45454f920025502açsdçaDJk2", "externalId": "9245"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "message": "Call in progress"
}

Update schedule


Update an existing schedule call.

Arguments
date Datetime (optional)
The date to schedule a call, the schedule will happen at the hour informed in the timezone of the client (based on phone number), if its not informed, the call will be performed now. (e.g., 2020-01-01 10:00:00)

PAY ATENCION: Its important to take care scheduling hours to prevent call in inopportune times.

Returns

Returns the confirmation that call is updated.
PUT /v1/call/{id}
curl https://api.targg.com/v1/call/54a4fs4545fsa45ffa54 \ 
  -X PUT -d '{"date": "2025-01-01 10:00:00"} -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "message": "Call updated"
}

Delete schedule


Delete an existing schedule call.

Arguments
No arguments.


Returns

Returns a message warning if the deletion was completed.
DELETE /v1/call/{id}
curl https://api.targg.com/v1/call/54a4fs4545fsa45ffa54 \ 
  -X DELETE -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "message": "Call deleted"
}

Call to schedule call


Call to schedule call right now.

Arguments
No arguments.


Returns

Returns a message warning if the call is in progress or not.
POST /v1/call/{id}/ring
curl https://api.targg.com/v1/call/54a4fs4545fsa45ffa54 \ 
  -X POST -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "message": "Call in progress"
}

Get all calls


Retrieves all your calls paginated.

Arguments

limit Integer (optional)
Maximum number of calls to bring per page, default = 10, maximum = 50.

page Integer (required)
the current page.

ini_date Date (optional)
Filter of initial date (e.g., 2020-01-01).

end_date Date (optional)
Filter of End date (e.g., 2020-01-01).

campaigns Array of String (optional)
Array of ids of campaigns. (e.g., ["id1", "id2", "id3"]).

contacts Array of String (optional)
Array of ids of contacts. (e.g., ["id1", "id2", "id3"]).

status Enum (optional)
Array of status. The only values permited are scheduled, schedule_done, failed, started, hanged and finished. (e.g., ["finished", "scheduled"])



Returns

Returns the call objects paginated.
GET /v1/calls
curl https://api.targg.com/v1/calls?limit=15&page=1 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "calls": [
        {
            "data": [
                {
                    "_id": "5e5c635cf9fba3141889d981",
                    "userId": "5e5c59083b76bf0040940602",
                    "company": "5e5c59083b76bf0040940602",
                    "toNumber": "5519996042828",
                    "campaign": "5e5c402627d49b2b7468aa12",
                    "environment": "production",
                    "inbound_outbound": "outbound",
                    "contact": "5e5c4ab1d6763d3bb0dc272d",
                    "contactSent": "5e5c4ab1d6763d3bb0dc272d",
                    "templateId": "5e4ac1c86c592400175ac279",
                    "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNvbnRhdG9AdGFyZ2cuY29tIiwiX2lkIjoiNWU1YzU5MDgzYjc2YmYwMDQwOTQwNjAyIiwiY29tcGFueSI6IjVlNWM1OTA4M2I3NmJmMDA0MDk0MDYwMiIsImNvdW50cnkiOiJicmF6aWwiLCJhcGkiOnRydWUsImlhdCI6MTU4MzExMDQwOH0._gdoGO0XpxQ3_USe1jCd3BOPNRwOJvMpvUd0apw_mzs",
                    "respFinal": [],
                    "internalAudios": {},
                    "audiosFinalToPlay": {},
                    "templateFinal": {
                        "_id": "5e4ac1c86c592400175ac279",
                        "phone_test_inbound": [],
                        "name": "E-commerce",
                        "objective": "objective9",
                        "category": "category4",
                        "is_public": true,
                        "template_base": null,
                        "language": "pt-br",
                        "type": "outbound",
                        "forks_number": 0,
                        "company": "5e5c59083b76bf0040940602",
                        "description": "Vendas, abandono de carrinho.",
                        "priority": 0,
                        "createdAt": "2020-02-17T16:39:36.808Z",
                        "updatedAt": "2020-02-17T16:39:36.808Z",
                        "__v": 0
                    },
                    "endpointAsterisk": "SIP/from-pstn5/",
                    "balance": [],
                    "externalId": null,
                    "id_custom": "5519996042828_1583113032",
                    "call_uuid": "6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2",
                    "status": "finished",
                    "timestamp": 1583113063,
                    "fullConversation": [],
                    "audios": {
                        "url": "https://s3-sa-east-1.amazonaws.com/targg-robot-upload-audios/records/maehmtuxjn_6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2.wav",
                        "duration": 9.88225
                    },
                    "rating": {
                        "_id": "5e5c635cf9fba3141889d981",
                        "userId": "5e5c59083b76bf0040940602",
                        "company": "5e5c59083b76bf0040940602",
                        "toNumber": "5519996042828",
                        "campaign": "5e5c402627d49b2b7468aa12",
                        "environment": "production",
                        "inbound_outbound": "outbound",
                        "contact": "5e5c4ab1d6763d3bb0dc272d",
                        "contactSent": "5e5c4ab1d6763d3bb0dc272d",
                        "templateId": "5e4ac1c86c592400175ac279",
                        "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNvbnRhdG9AdGFyZ2cuY29tIiwiX2lkIjoiNWU1YzU5MDgzYjc2YmYwMDQwOTQwNjAyIiwiY29tcGFueSI6IjVlNWM1OTA4M2I3NmJmMDA0MDk0MDYwMiIsImNvdW50cnkiOiJicmF6aWwiLCJhcGkiOnRydWUsImlhdCI6MTU4MzExMDQwOH0._gdoGO0XpxQ3_USe1jCd3BOPNRwOJvMpvUd0apw_mzs",
                        "respFinal": [],
                        "internalAudios": {},
                        "audiosFinalToPlay": {},
                        "templateFinal": {
                            "_id": "5e4ac1c86c592400175ac279",
                            "phone_test_inbound": [],
                            "name": "E-commerce",
                            "objective": "objective9",
                            "category": "category4",
                            "is_public": true,
                            "template_base": null,
                            "language": "pt-br",
                            "type": "outbound",
                            "forks_number": 0,
                            "company": "5e5c59083b76bf0040940602",
                            "description": "Vendas, abandono de carrinho.",
                            "priority": 0,
                            "createdAt": "2020-02-17T16:39:36.808Z",
                            "updatedAt": "2020-02-17T16:39:36.808Z",
                            "__v": 0
                        },
                        "endpointAsterisk": "SIP/from-pstn5/",
                        "balance": [],
                        "externalId": null,
                        "id_custom": "5519996042828_1583113032",
                        "call_uuid": "6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2",
                        "status": "finished",
                        "timestamp": 1583113063,
                        "fullConversation": [],
                        "audios": {
                            "url": "https://s3-sa-east-1.amazonaws.com/targg-robot-upload-audios/records/maehmtuxjn_6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2.wav",
                            "duration": 9.88225
                        }
                    },
                    "contactUni": {
                        "_id": "5e5c4ab1d6763d3bb0dc272d",
                        "blockedCampaigns": [],
                        "tags": [],
                        "phones": [
                            {
                                "_id": "5e5c4ab1d6763d3bb0dc272e",
                                "number": "5519996042828",
                                "main": true,
                                "not_disturb": false
                            }
                        ],
                        "rescheduleCampaigns": [],
                        "aditionalFields": [],
                        "name": "Raphael Linz",
                        "company": "5e5c59083b76bf0040940602",
                        "language": "pt-br",
                        "email": "[email protected]",
                        "has_aditional_fields": false,
                        "status": "active",
                        "blacklist": false,
                        "createdAt": "2020-03-01T23:52:17.782Z",
                        "updatedAt": "2020-03-01T23:52:17.782Z",
                        "__v": 0
                    },
                    "campaignUni": {
                        "_id": "5e5c402627d49b2b7468aa12",
                        "tags": [],
                        "allDays": [],
                        "title": "Campaign 1",
                        "status": "active",
                        "templateId": "5e4ac1c86c592400175ac279",
                        "company": "5e5c59083b76bf0040940602",
                        "internalAudios": null,
                        "externalId": "Testx",
                        "calls_per_day": 0,
                        "has_holiday": false,
                        "createdAt": "2020-03-01T23:07:18.072Z",
                        "updatedAt": "2020-03-01T23:07:18.072Z",
                        "__v": 0
                    }
                }
            ],
            "count": [
                {
                    "_id": null,
                    "total": 1
                }
            ]
        }
    ]
}

Get call details


Retrieves all details of a specific call.

Arguments

No arguments.


Returns

Return the call object.
GET /v1/call/:id
curl https://api.targg.com/v1/call/4245erfasffas245562ucjgxs \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "call": {
        "_id": "5e5c635cf9fba3141889d981",
        "userId": "5e5c59083b76bf0040940602",
        "company": "5e5c59083b76bf0040940602",
        "toNumber": "5519996042828",
        "campaign": "5e5c402627d49b2b7468aa12",
        "environment": "production",
        "inbound_outbound": "outbound",
        "contact": "5e5c4ab1d6763d3bb0dc272d",
        "contactSent": "5e5c4ab1d6763d3bb0dc272d",
        "templateId": "5e4ac1c86c592400175ac279",
        "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNvbnRhdG9AdGFyZ2cuY29tIiwiX2lkIjoiNWU1YzU5MDgzYjc2YmYwMDQwOTQwNjAyIiwiY29tcGFueSI6IjVlNWM1OTA4M2I3NmJmMDA0MDk0MDYwMiIsImNvdW50cnkiOiJicmF6aWwiLCJhcGkiOnRydWUsImlhdCI6MTU4MzExMDQwOH0._gdoGO0XpxQ3_USe1jCd3BOPNRwOJvMpvUd0apw_mzs",
        "respFinal": [],
        "internalAudios": {},
        "audiosFinalToPlay": {},
        "templateFinal": {
            "_id": "5e4ac1c86c592400175ac279",
            "phone_test_inbound": [],
            "name": "E-commerce",
            "objective": "objective9",
            "category": "category4",
            "is_public": true,
            "template_base": null,
            "language": "pt-br",
            "type": "outbound",
            "forks_number": 0,
            "company": "5e5c59083b76bf0040940602",
            "description": "Vendas, abandono de carrinho.",
            "priority": 0,
            "createdAt": "2020-02-17T16:39:36.808Z",
            "updatedAt": "2020-02-17T16:39:36.808Z",
            "__v": 0
        },
        "endpointAsterisk": "SIP/from-pstn5/",
        "balance": [],
        "externalId": null,
        "id_custom": "5519996042828_1583113032",
        "call_uuid": "6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2",
        "status": "finished",
        "timestamp": 1583113063,
        "fullConversation": [],
        "audios": {
            "url": "https://s3-sa-east-1.amazonaws.com/targg-robot-upload-audios/records/maehmtuxjn_6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2.wav",
            "duration": 9.88225
        }
    }
}

Get all blacklisted contacts


Retrieves all blacklist contacts.

Arguments

limit Integer (optional)
Maximum number of contacts to bring per page, default = 10, maximum = 50.

page Integer (required)
the current page.


Returns

Returns the contacts objects paginated.
GET /v1/blacklist
curl https://api.targg.com/v1/blacklist?limit=15&page=1 \ 
  -H "Bearer eyJ222sf6IkpXVCJ9.eyJlbWasf2244sdfNzk0YjM0YWU0MTUasdasd124124sgdhQ4BRSyryrery46646c"
RESPONSE
{
    "response": true,
    "contacts": [
        {
            "data": [],
            "count": [
                {
                    "_id": null,
                    "total": 0
                }
            ]
        }
    ]
}

Get call Webhook


Retrieve the status of a call.
This webhook will receive any update of status of a call.

The data will be a call Object.

The method of the webhook will be POST.

The webhook endpoint can be configured at this link.

The webhook will be triggered when status of call changes. The status that will be send are: schedule,schedule_done, started, hanged, finished or failed.

You can see more details about call object here.
WEBHOOK OBJECT
{
    "_id": "5e5c635cf9fba3141889d981",
    "userId": "5e5c59083b76bf0040940602",
    "company": "5e5c59083b76bf0040940602",
    "toNumber": "5519996042828",
    "campaign": "5e5c402627d49b2b7468aa12",
    "environment": "production",
    "inbound_outbound": "outbound",
    "contact": "5e5c4ab1d6763d3bb0dc272d",
    "contactSent": "5e5c4ab1d6763d3bb0dc272d",
    "templateId": "5e4ac1c86c592400175ac279",
    "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNvbnRhdG9AdGFyZ2cuY29tIiwiX2lkIjoiNWU1YzU5MDgzYjc2YmYwMDQwOTQwNjAyIiwiY29tcGFueSI6IjVlNWM1OTA4M2I3NmJmMDA0MDk0MDYwMiIsImNvdW50cnkiOiJicmF6aWwiLCJhcGkiOnRydWUsImlhdCI6MTU4MzExMDQwOH0._gdoGO0XpxQ3_USe1jCd3BOPNRwOJvMpvUd0apw_mzs",
    "respFinal": [],
    "internalAudios": {},
    "audiosFinalToPlay": {},
    "templateFinal": {
        "_id": "5e4ac1c86c592400175ac279",
        "phone_test_inbound": [],
        "name": "E-commerce",
        "objective": "objective9",
        "category": "category4",
        "is_public": true,
        "template_base": null,
        "language": "pt-br",
        "type": "outbound",
        "forks_number": 0,
        "company": "5e5c59083b76bf0040940602",
        "description": "Vendas, abandono de carrinho.",
        "priority": 0,
        "createdAt": "2020-02-17T16:39:36.808Z",
        "updatedAt": "2020-02-17T16:39:36.808Z",
        "__v": 0
    },
    "endpointAsterisk": "SIP/from-pstn5/",
    "balance": [],
    "externalId": null,
    "id_custom": "5519996042828_1583113032",
    "call_uuid": "6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2",
    "status": "finished",
    "timestamp": 1583113063,
    "fullConversation": [],
    "audios": {
        "url": "https://s3-sa-east-1.amazonaws.com/targg-robot-upload-audios/records/maehmtuxjn_6ad9cd6e-f6e3-4994-bb5d-859e9aaaeed2.wav",
        "duration": 9.88225
    }
}