Welcome to the aNinja API specification
Welcome to th aNinja REST API documentation. You can use this information to integrate your apps and get even more value out of aNinja.
Authentication aNinja uses an API Key to authenticate access to the API.
Obtain your API in your Account Settings. (See https://help.aninja.com/knowledge-base/find-aninja-api-key/)
aNinja expects for the API key to be included in all API requests to the server in a header that looks like the following:
Authorization:
Make sure to replace with your assigned API key.
We recommend using the “forms-3rdparty-integration” WordPress plugin in order to integrate your WordPress Contact forms submissions into aNinja. Here are the steps:
Get your API key in your User Settings when logged into ANinja. Install & activate WP plugin in your WordPress installation: forms-3rdparty-integration Once the plugin is installed, access the plugins’ setting to configure it as following:
Add a new 3rd-party service, e.g. name it “ANinja” Select the forms you want to attach the service to
Add Endpoint URL (replace with main user API key)
https://aninja.com/api/v1/contactform/?apikey=YOUR_API_KEY_HERE
Map Form fields (without CF7 brackets - see what field names are defined and map to Aninja API fields)
The following example is of an API request in Javascript. You can customize off of the following examples to suit your actual code / use case.
Example use cases: Squarespace, Shopify
ajax({
type: 'POST',
url: "https://aninja.com/api/v1/contactform/?apikey=YOUR_API_KEY_HERE",
data:$.param({contact_name : contact_name}) + "&"+ $.param({contact_email1 : contact_email1}) + "&"+ $.param({contact_phone1 : contact_phone1})+ "&"+ $.param({company_name : company_name}),
success: function (data) {
alert('success');
}
});
The following is more specific to Squarespace (add in the "Page section settings -> Advanced tab -> Page header code injection text area" section for the page where you have the form you want to forward into aNinja)
// SQUARESPACE - example 1
// Add in javascript advanced:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('form').submit(function(e) {
var contact_name = $("input[name='fname']").val();
var contact_email1 = $( "input[name='email']").val();
var phone_areacode = $('*[data-title="Areacode"]').val();
var phone_prefix= $('*[data-title="Prefix"]').val();
var phone_line = $('*[data-title="Line"]').val();
var contact_phone1 = phone_areacode+phone_prefix+phone_line;
var subject = $($('select')[0]).val();
var pref_contact_method = $($('select')[1]).val();
var message = $('textarea#textarea-yui_3_17_2_1_1442700176413_134868-field').val();
$.ajax({
type: 'post',
url: "https://aninja.com/api/v1/contactform/?apikey=YOUR_API_KEY_HERE",
data: {
'contact_name': contact_name,
'contact_email1': contact_email1,
'contact_phone1': contact_phone1,
'your-comments': 'message: '+message+' subject:'+subject+' pref_contact_method: '+pref_contact_method
},
success: function (data) {
// alert('success');
}
});
});
});
</script>
// Squarespace - Example 2
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('form').submit(function(e) {
var contact_name = $("input[name='fname']").val() + ' '+ $("input[name='lname']").val();
var contact_email1 = $( "input[name='email']").val();
var subject = $('#text-yui_3_17_2_1_1525202684663_15908-field').val();
var message = $('textarea').val();
$.ajax({
type: 'POST',
url: "https://aninja.com/api/v1/contactform/?apikey=YOUR_API_KEY_HERE",
data: {
'contact_name': contact_name,
'contact_email1': contact_email1,
'your-comments': 'Subject: '+subject+' Message:'+message
},
success: function (data) {
alert('We have received your request, thank you');
}
});
});
});
</script>
The following are standard fields you can map to, in addition to any custom fields created in your application that you can see under Settings -> Custom fields
Category Field Aliases
Contact Contact.name contact_name | your-name
Contact Contact.firstname your-fname
Contact Contact.lastname your-lname
Contact Contact.email1 your-email
Contact Contact.phone1 your-phone | your-phone1
Lead Lead.note1 your-comments
Lead.Company Lead.Company.name your-company
Lead.Company Lead.Company.url
Lead.Company Lead.Company.description
API endpoint to "add" an activitycall
A successful call will return a response with status "success" with the data Should add the following field to the body in "form-data":
- contactitem_id
- lead_id
- contact_id
API endpoint to "update" an activitycall
A successful call will return a response with status "success" with the data Should add the following field to the body in "form-data":
- contactitem_id
API endpoint to "delete" an Activitycall.
API endpoint to "delete" an activitylog
API endpoint to "add" an activitylog
A successful call will return a response with status "success" with the data Should add the following field to the body in "form-data":
- contactitem_id
- lead_id
API endpoint to "update" an activitycall
A successful call will return a response with status "success" with the data Should add the following field to the body in "form-data":
- contactitem_id
- minutes
- note