We hope you love using the Shortmail API! Send all feature requests and bug reports to jonathanjulian@shortmail.com.
Reply to a Shortmail, update attributes
Mark a single message as read, update attributes
All API endpoints use standard REST-style HTTP requests and methods. Tell the API what format you would like by passing an Accept: header. We support application/json as well as application/xml. If Accept: is not passed, or if it is set to */*, json is returned. Examples here use curl and application/json. You are encouraged to set a custom USER_AGENT string when interacting with the api; this will allow us to better diagnose usage and help you with any issues.
All requests need to be authenticated. There are two ways to authenticate:
api_key, and then store it. With every subsequent request, pass the key in the HTTP header Shortmail-Api-Key. There is no need to ever re-request another key for that user.We recommend using the API KEY approach, since a client app can be built to handle any number of users simply by storing each's api_key. This allows for an app to service multiple users at a time, and never require the user to re-authenticate (no more password prompts!). The Basic Auth approach might be simpler if you are building a tool that only one Shortmail user will use at time, such as a utility that will download a single user's Shortmail to their computer. The drawback is that the user is required to have a password set.
Sign in to Shortmail, getting an api_key to access the rest of the API on behalf of this user. Pass credentials as either Shortmail email and password, or Shortmail email and Twitter access token/secret. Store the api_key for use between sessions - authenticating more than once per email address is not necessary, and is not suggested.
For accounts connected to Twitter:
For accounts with a password:
Accounts with a password can also request a key using Basic Auth.
200 success, 401 or 422 if authentication fails
# pass creds as params curl -d 'email=jonathanjulian@shortmail.com&password=mypassword' -H "Accept: application/json" http://api.shortmail.com/home/api/login # pass creds in Basic Auth curl -X POST -u jonathanjulian@shortmail.com:mypassword -H "Accept: application/json" http://api.shortmail.com/home/api/login
{
"address": {
"name": "Jonathan Julian",
"avatar_url": "http://a2.twimg.com/profile_images/1410547810/c1975-500_normal.png",
"id": 1,
"email": "jonathanjulian@shortmail.com"
},
"api_key": "JONATHAN'S API KEY"
}
Returns information for the current user
none
200 success
# pass api_key in the HTTP header curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" http://api.shortmail.com/home/api/user # pass creds in Basic Auth curl -u jonathanjulian@shortmail.com:mypassword -H "Accept: application/json" http://api.shortmail.com/home/api/user
{
"id": 1234,
"contact_email_address": {
"email": "jonathanjulian@example.com",
"name": "Jonathan Julian",
"full": "\"Jonathan Julian\" <jonathanjulian@example.com>"
},
"accounts": [{
"name": "Jonathan Julian",
"unseen_inbox_count": 5,
"total_inbox_count": 23,
"id": "jonathanjulian@shortmail.com",
"email_address": "jonathanjulian@shortmail.com",
},{
"name": "Jonathan Julian",
"unseen_inbox_count": 0,
"total_inbox_count": 11,
"id": "jonathanjulian@shortmail.me",
"email_address": "jonathanjulian@shortmail.me"
}],
"evernote": {
"id": 4567,
"shard_id": "s7",
"username": "jonathanjulian"
},
"connected_to": [{
"id": 984
"enabled": true
"local_email": "jonathanjulian@shortmail.com",
"remote_email": "jonathanjulian@example.com",
"move_messages": true,
"only_contacts": false
}]
}
Returns an array of accounts with inbox counts and unread counts
none
200 success
# pass api_key in the HTTP header curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" http://api.shortmail.com/home/api/accounts # pass creds in Basic Auth curl -u jonathanjulian@shortmail.com:mypassword -H "Accept: application/json" http://api.shortmail.com/home/api/accounts
[
{
"name": "Jonathan Julian",
"unseen_inbox_count": 5,
"total_inbox_count": 23,
"id": "jonathanjulian@shortmail.com",
"email_address": "jonathanjulian@shortmail.com"
},{
"name": "Jonathan Julian",
"unseen_inbox_count": 0,
"total_inbox_count": 11,
"id": "jonathanjulian@shortmail.me",
"email_address": "jonathanjulian@shortmail.me"
}
]
Get the contents of the inbox for a given account. The posts array contains each message in the conversation, along with the details about the sender. The addresses array contains all the participants in the conversation, including yourself.
200 success
# pass api_key in the HTTP header curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" http://api.shortmail.com/home/api/conversations?aid=jonathanjulian@shortmail.com # pass creds in Basic Auth curl -u jonathanjulian@shortmail.com:mypassword -H "Accept: application/json" http://api.shortmail.com/home/api/conversations?aid=jonathanjulian@shortmail.com
[
{
"id": 164996,
"subject": "test message zebra",
"is_public": false,
"is_open": false,
"public_url": null,
"is_silenced": false,
"addresses": [{
"id": 3028982,
"email": "jonathanjulian@shortmail.com",
"name": "Jonathan Julian",
"avatar_url": "http://www.gravatar.com/avatar/fc661b3e9c498fe417a8b20c7a35c704.png?d=mm&s=64",
"profile_url": "http://shortmail.com/jonathanjulian",
"new": false,
"internal": true
}],
"posts": [{
"text": "<p>test message zebra</p>",
"plain_text": "test message zebra",
"id": 134652,
"share_id": 325307,
"conversation_id": 164996,
"flags": null,
"posted_at": "2011-11-10 17:07:11.663164"
"human_posted_at": "Nov 10 at 05:07 PM",
"updated_at": "2011-11-10 17:07:12.017098",
"seen_at": "2011-11-10 17:07:12.015383",
"message_updated_at": "2011-11-10 17:07:12.017098",
"archived_at": "2011-11-10 17:07:12.015301",
"short_links": {},
"sender": {
"id": 3028982,
"email": "jonathanjulian@shortmail.com",
"name": "Jonathan Julian",
"avatar_url": "http://www.gravatar.com/avatar/fc661b3e9c498fe417a8b20c7a35c704.png?d=mm&s=64",
"profile_url": "http://shortmail.com/jonathanjulian",
"internal": true
}
}]
}
]
Get changes to your inbox since a certain time, in the same format as the inbox query. If the client keeps track of the last time the server was queried, then this call can quickly return only changes. NOTE: "changes" includes message removal and participant additions. Consider this a "diff" between your stored view and the server. Removed conversations are returned here with an empty posts array.
YYYY-MM-DD HH:MM:SS200 success. An empty array means no changes.
# pass api_key in the HTTP header curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" http://api.shortmail.com/home/api/conversations/changes?aid=jonathanjulian@shortmail.com&since=2012-02-21+12:34:55 # pass creds in Basic Auth curl -u jonathanjulian@shortmail.com:mypassword -H "Accept: application/json" http://api.shortmail.com/home/api/conversations/changes?aid=jonathanjulian@shortmail.com&since=2012-02-21+12:34:55
[]
Send a Shortmail.
private, public, open (defaults to private)200 success, with the message, in the format above
422 if sending the message fails, along with errors
curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" -d 'aid=jonathanjulian@shortmail.com&subject=The Shortmail API=Welcome to the API!&recipients=you@example.com' 'http://api.shortmail.com/home/api/conversations'
Example error message
{
"errors": {
"text": [
"should be short - keep messages less than 500 chars please"
]
}
}
Send a reply to a message, or set attributes on a conversation. Pass any combination of params.
200 success, with the message, in the format above
If the conversation was deleted, 200 success with just the conversation id
422 if sending the message or anything else fails, along with errors
Reply to a conversation, also archiving it:
curl -X PUT -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" -d 'aid=jonathanjulian@shortmail.com&reply=I love it!&archive=true' 'http://api.shortmail.com/home/api/conversations/165061'
(returns the same message array as above)
Deleting a conversation:
curl -X PUT -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" -d 'mark_as_deleted=1&last_posted_at=2012-02-24+13:26:44' 'http://api.shortmail.com/home/api/conversations/165061'
{
"id" :165061,
"posts": []
}
Mark a message as seen or unseen.
200 success, with no body
422 if anything fails, along with errors
Mark a single message as seen:
curl -X PUT -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" -d 'aid=jonathanjulian@shortmail.com&seen=true' 'http://api.shortmail.com/home/api/conversations/165061/posts/232766'
Search the archive for matching messages.
200 success, with the matching messages in the format above
curl -H "Shortmail-Api-Key: USER API KEY" -H "Accept: application/json" 'http://api.shortmail.com/home/api/conversations/search?query=cats&per_page=25'