User session, sign in and sign up
Some actions require a valid user session, for example, sending a package to an email recipient, or creating download automations. Other actions like uploading to a portal do not require a user session. When you try to perform an action that requires a session without being logged in, the service will respond with a 401 Unauthorized
status code and the following error body:
{
"code": 262146,
"message": "session is nil"
}
Get current user session
To see which user is currently signed in to the service, use the following request:
curl -X GET http://localhost:8080/api/v1/login
The response will look like the following:
{
"user": {
"email": "[email protected]",
"id": "01CWEEY5PT3535ETT4TH9NYZVP",
"name": "Firstname Lastname"
},
"teams": [
{
"custom_expiry_default": 30,
"custom_expiry_enabled": true,
"download_limit_default": 12,
"download_limit_enabled": true,
"id": "01CWEEY60MREFF7PPYZ82QSQ9J",
"max_email_recipients": 30,
"name": "Acme",
"subdomain": "acme"
},
...
]
}
Where:
user
object contains logged-in user attributesteams
is an array of all teams that the user belongs to, with details like limits and general settings as configured for that team
You may also retrieve the teams that the current signed-in user belongs to, as follows:
curl -X GET http://localhost:8080/api/v1/teams
Sign in
To sign in with an existing MASV account:
curl -X POST -H "Content-Type: application/json" http://localhost:8080/api/v1/login -d '{"email":"[email protected]","password":"top_secret_password"}'
The response body will look exactly the same as that in the previous section (get user session).
Sign up
To sign up for a new MASV account:
curl -X POST -H "Content-Type: application/json" http://localhost:8080/api/v1/signup -d '{"email":"EMAIL","password":"PASSWORD","name":"FIRSTNAME LASTNAME"}'
Note that a successful sign up will automatically sign you in, so an additional sign in is not required.
API-Key Authentication
Instead of using the login/signup endpoints, users can provide an API Key when starting the transfer-agent with the api-key
command line argument. For more information on how to create API Keys, see API Keys
./masv-agent -api-key='{api_key}'