Authentication

Getting Started with Authentication

In order to access our API, you need to have a Shark Agent account.

If you don't have a Shark Agent account yet, you can sign up by following link: https://app.sharkagent.com/signup

All API requests require authentication. You need to authenticate with your email and password to receive a token via our API call. You will need to modify the HTTP request header with your token on every request.

-H Authorization: Bearer YOUR_TOKEN_HERE

Data Formats

Shark Agent API media types determine how the API serializes and deserializes the HTTP message body. We use JSON as the primary data type. 

-H Content-Type: application/json; charset=utf-8

Request Example

All requests start with https://app.sharkagent.com/ This endpoint will be used for every request. First start by authenticating to get a token.

In curl, that looks like:

curl --data "email=test@test.com&password=password" https://app.sharkagent.com/auth/local

Please note: the email and password in this documentation are fake, replace with the correct credentials.

Response Example

POST /auth/local will authenticate you with the email and password you provide

{
    "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NTJiNThkNjllYmViZTk3MDc2ZjAyMTIi",
    "user":{
        "firstName":"John",
        "lastName":"Doe",
        "email":"john@doe.com",
        "country":"United States",
        "role":"admin",
        "subscription":"monthly",
        "_id":"552b58d69ebebe97076f0212",
        "account":"552b58d69ebebe97076f0213",
        "status":"active",
        "created":"2015-04-13T05:49:10.396Z",
        "hasMarketing":false
     } 
}

Response Status Codes

  • 200 - Request was successful.
  • 201 - Object was successfully created.
  • 400 - Wrong input parameter. See response for details.
  • 401 - User not found.
  • 403 - Access denied. User with granted token does not have access to requested resource.
  • 404 - The requested resource could not be found. See response content for details.
  • 500 - Internal Server Error. See response for additional details.

Login (Get Token)

In order to do anything with Shark Agent, you must retrieve a token from the server by logging in.

Request:

POST /auth/local

will authenticate you with the email and password you provide

Response:

{
    "token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NTJiNThkNjllYmViZTk3MDc2ZjAyMTIi",
    "user":{
        "firstName":"John",
        "lastName":"Doe",
        "email":"john@doe.com",
        "country":"United States",
        "role":"admin",
        "subscription":"monthly",
        "_id":"552b58d69ebebe97076f0212",
        "account":"552b58d69ebebe97076f0213",
        "status":"active",
        "created":"2015-04-13T05:49:10.396Z",
        "hasMarketing":false
     } 
}

Sign Up

POST /api/user will authenticate you with the email and password you provide

Request:

POST /api/user
{
	"firstName": "John",
	"lastName": "Doe",
	"email": "john@doe.com"
	"password": "password",
	"primaryPhone": "2334059199",
}

Response:

{
	"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ90.qdRh544O1zsNKDcprS4W0qDTlnNv4cIDLGIofLiabro",
	"user": {
		"firstName":"John",
		"lastName":"Doe",
		"email":"john@doe.com",
		"country":"United States",
		"primaryPhone":"2334059199",
		"role":"admin",
		"subscription":"freetrial",
		"_id":"55a4871dba8b45aa1f91ed85",
		"account":"55a4871dba8b45aa1f91ed86",
		"status":"active",
		"created":"2015-07-14T03:50:53.396Z",
		"hasMarketing":false
	}
}

Help Us Make our API Better

Please tell us how we can make the API better. If you have a specific feature request or if you found a bug, please email us at info@sharkagent.com

Still need help? Contact Us Contact Us