Contacts API Methods

Table of Contents:


(info) Note: Notice that in each API call you must provide the List ID that you are working on, otherwise the default List ID will be used. 

Methods Summary

GET /api/contacts/by_email/<Contact Email>

Description 

This method returns a single contact data.

Response Example

GET URL: https://api.ongage.net/<list_id>/api/by_email/<Contact Email>

Error Codes

  • 403 - Permission error
  • 404 - Unauthorized / Email not found

GET /api/contacts/by_id/<Contact ID>

Description 

This method returns a single contact data.

Response Example

GET URL: https://api.ongage.net/<list_id>/api/by_id/<Contact ID>

Error Codes

  • 403 - Permission error
  • 404 - Unauthorized / Contact not found

GET /api/contacts/add

Description 

Tunneling from get to post, for POST api/contacts. It supports only adding 1 contact at a time.

Example

POST /api/v2/contacts/

Description 

This method is used to create a new contact, or multiple contacts.

Request

email

Required string - Email address of new contact

list_id

Optional number - List ID number to add this contact to. If omitted, the default list will be used.

Note: list_id cannot be indicated in the body of the request for this specific API command. To indicated a non-default list, use the URL route param e.g. <List ID>/api/v2/contacts

overwrite

Optional boolean - Update (aka overwrite) the data fields for an existing contact (i.e. existing email address). Default: false. When using the overwrite option, you must indicate the "fields :" object, with the list fields you want to update/overwrite, as can be seen in the 3rd example below.

You can include any custom list field in your list as well For adding a single contact:

POST URL: https://api.ongage.net/<list_id>/api/v2/contacts/

or:

For adding multiple contacts:

or:

Response

Version 2

KeyDescription
rowsCount of emails provided
successCount of contacts that were created+updated+revived successfully
createdCount of contacts that were created successfully
created_emailsList of all contact emails that created successfully, with their contact IDs
updatedCount of updated contacts (when using "overwrite" flag)
updated_emailsList of all contact emails that updated successfully, with their contact IDs
revivedCount of revived contacts (were deleted and now active)
revived_emailsList of all contact emails that revived successfully, with their contact IDs
failedCount of contacts failed to be added
failed_emailsList of all contact emails that failed, with the failed reasons

Version 1 (POST api/contacts) - Deprecated

KeyDescription
rowsCount of emails provided
successCount of contacts that were created+updated+revived successfully
createdCount of contacts that were created successfully
updatedCount of updated contacts (when using "overwrite" flag)
revivedCount of revived contacts (were deleted and now active)
failedCount of contacts failed to be added
messagesFailed reasons, grouped by contact emails
_idNewly created contact ID
_idsNewly created contacts ID

Response Example - bulk contact add to list

Error Codes

  • 400 - Invalid data in request
  • 404 - List not found
  • 412 - Invalid data in request
  • 500 - General error

PUT /api/v2/contacts/

Description 

This method is used to update contacts based on "list_id" and "email address" or "Contact ID".

Note: "list_id" can be within each contact, or on the payload root level.

Request

email

Required string - Email address of the contact or Contact ID

id

Optional string - ID of the contact, can be used instead of Email

list_id

Optional number - List ID number to add this contact to. If omitted, the default list will be used.

Note: list_id cannot be indicated in the body of the request for this specific API command. To indicated a non-default list, use the URL route param e.g. <List ID>/api/v2/contacts

You can include any custom list field in your list as well For updating a single contact:

PUT URL: https://api.ongage.net/<list_id>/api/v2/contacts/

or:

or:

For adding multiple contacts:

or:

Response

Version 2

KeyDescription
rowsCount of emails provided
successCount of contacts that were updated successfully
success_emailsList of all contact emails that updated successfully, with their contact IDs
failedCount of contacts failed to be updated
failed_emailsList of all contact emails that failed, with the failed reasons

Version 1 (PUT api/contacts) - Deprecated

KeyDescription
rowsCount of emails provided
successCount of contacts that were updated successfully
success_by_domainCounts of contacts updated successfully, per domain
failedCount of contacts failed to be updated
failed_by_domainCounts of contacts failed to be updated, per domain

Error Codes

  • 412 - Validation errors

POST /api/v2/contacts/change_status

Description 

This method is used to change contact status (i.e., set it active or inactive status), based on email and list.
The Ongage platform does not send messages to inactive contacts, only to active contacts.

Request

list_id

Optional integer - List ID. Default: Your account default list

change_to

Required string - "resubscribe" / "unsubscribe" / "remove" / "bounce" / "complaint" / "soft_bounce"

(resubscribe == set to active; remove is a hard delete from DB; bounce, unsubscribe and complaint are inactive statuses; soft_bounce is an active status).
See: Delivery Glossary & FAQ for more details on the above.

emails

Required array or strings - Emails

ocx_child_id

Optional integer - Use this parameter to associate the unsubscribe with an Ongage campaign and thus you will see these unsubscribe stats in all campaign analytic reports.

(info) If you don't send this parameter, then unsubscribe will be performed, but stats won't be reflected in any of the campaign analytic reports.

ocx_connection_id

Optional integer - Use this parameter for associating the unsubscribe stats with a connection ID in case of a transactional mailing ID being used

Example

POST URL: https://api.ongage.net/<list_id>/api/v2/contacts/change_status

Response

Version 2

KeyDescription
rowsCount of emails provided
successContacts count succeed to change status
success_emailsList of all contact emails that changed successfully, with their contact IDs
failedContacts count failed to change status
failed_emailsList of all contact emails that failed, with the failed reasons

Version 1 - (POST /api/contacts/remove) - Deprecated

KeyDescription
rowsCount of emails provided
successContacts count succeed to change status
failedContacts count failed to change status
results_by_domainList of all domains that changed
removed_contact_idsList of all contacts IDs that removed - For "remove" / "bounce" / "complaint"
contact_idsList of all contacts IDs that changed - For "resubscribe" / "soft_bounce" or "unsubscribe"
success_contactsList of all contact emails that were changed successfully
failed_contactsList of all contact emails that failed, grouped by the failed reasons
success_contactsContacts count failed to change status

Error Codes

  • 412 - Validation error

PUT /api/contacts/change_email

Description 

This method is used to change contact key email address. This method currently supports only changing of a single contact. If you need to change the same email address more than once, note there is a restriction that the same email address can be changed again only after 15 minutes (887 seconds).

Request

email

Required string - Existing contact email address

new_email

Required string - New email address

Example

PUT URL: https://api.ongage.net/<list_id>/api/contacts/change_email

Response

KeyDescription
rowsCount of emails provided
successCount of contacts that were updated successfully
success_emailsList of all contact emails that updated successfully, with their contact IDs
failedCount of contacts failed to be updated
failed_emailsList of all contact emails that failed, with the failed reasons

Error Codes

  • 412 - Validation errors

POST /api/contacts/delete

Description 

This method deletes a contact based on id.

Request

POST URL: https://api.ongage.net/<list_id/api/contacts/delete

contact_id

Required string - Unique identifier of a particular contact

contact_ids

Optional array - list of contact IDs

Response

The response will include deleted contact fields.

Error Codes

  • 400 - Missing contact ID(s)
  • 412 - Validation errors

GET /api/contacts/cross_account?email=example@example.com

Description 

This method is used to get contacts from all allowed lists by email address

Request

email

Required string - Email address

(info) Please note that the time zone is not supported as yet and GMT will be used.

Response Example