20 A/B Testing Tools for Mobile Apps / Autosend REST API

REST API

The most flexible way to integrate Autosend in your app is to use our RESTful API. Whether you’re developing an Android mobile app or a Ruby on Rails web app, the Autosend RESTful API is all you need.

Get Started

 

Authentication

The Autosend REST API uses basic auth to authenticate the request. You can find your required App Key and API Secret within your Autosend account in the Setup section.  

Endpoint

The API endpoints are only available over a secure connection (https) and have the following format:
  • https://app.autosend.io/api/v1/
 

Error Codes

  • 200 – The request was successful
  • 400 – The request was missing a required parameter
  • 401 – The credentials provided are invalid or improper
  • 403 – The account is not in an active state
  • 429 – Too many API requests. Your account is limited to 8 requests per second

Identify a User

HTTP Method: PUT The next step is identifying a user. This is more than likely a user who is logged in to your website. This is how Autosend knows who triggered an event (next section) and who to send a message to. You would also want to add this code to every page a user is logged in. The only required parameter is the user’s ID, but you should probably provide email, name, and phone (country calling code followed by the number, for example 15555555555 where 1 is the country calling code). If a user already exists with the provided id, their information will be updated with any provided parameters. The endpoint takes the following format:
  • https://app.autosend.io/api/v1/customers/<USER_ID>
  • Replace <USER_ID> with the logged in user’s ID
curl -X PUT https://app.autosend.io/api/v1/customers/123456 \
	-u [APP_KEY]:[API_SECRET] \
	-d "name=John Smith" \
	-d "phone=15555555555"
 

Here is a list of all the available parameters:

  • id – A unique ID that you use to identify the logged in user. This should be part of the URL
  • email – The user’s email address
  • name – the user’s name
  • phone – the user’s mobile phone number (country calling code followed by the number, for example 15555555555 where 1 is the country calling code)
 

Custom Parameters

Outside of the mentioned parameters above, you can provide any custom parameters you want. These user attributes can then be used when creating your message by using the attribute format of [[data ATTRIBUTE_NAME]]. For example, if you provided a parameter called twitter_name, when creating your message within your Autosend account you can refer to that parameter with the following: [[data twitter_name]]
curl -X PUT https://app.autosend.io/api/v1/customers/123456 \
	-u [APP_KEY]:[API_SECRET] \
	-d "name=John Smith" \
	-d "twitter_name=getautosend" \
	-d "phone=15555555555"
 

Delete a User

HTTP Method: DELETE If you want to delete a user, only the id in the URL path and your basic auth credentials are necessary. The HTTP method must also be DELETE
curl -X DELETE https://app.autosend.io/api/v1/customers/123456 \
	-u [APP_KEY]:[API_SECRET]

Track an Event

HTTP Method: POST Finally, you’ll want to track an event. An event is an action a user takes in your app, whether it’s a button click, a screen swipe, or perhaps even a more specific action such as using a promo code. Simply provide the event parameter and a name for the event.
curl -X POST https://app.autosend.io/api/v1/customers/123456/track \
	-u [APP_KEY]:[API_SECRET] \
	-d "event=started_trial"

 

Posted in: Installation