Skip to content

API Keys

The recommended way to authorize user requests is with an API key. For other requests, like accessing packages and transfers, the MASV API requires web tokens.

API keys simplify integration with the MASV API in these ways:

  • The username and password do not need to be hardcoded or stored.
  • The key does not require a refresh after expiration every few days.
  • An API key, while active, does not require the user to periodically answer multi-factor authentication (MFA) challenges.

An API key gives your application the same permissions as the MASV user from which it was created. Users with these roles can create API keys:

  • Owner
  • Admin
  • Integration Manager

Admins and Integration Managers can manage only the API keys they create; Owners have full access to manage all API keys for the Team. To learn more about user roles and permissions, see the MASV access policy.

You can create and manage API keys with the MASV Web App. Authorized users can create API keys for any Team that they belong to.

Your application can also create API keys programmatically:

MethodRoute
POST/teams/{team_id}/api_keys
NameTypeRequiredDescription
X-User-TokenStringYesJSON Web Token. See Web Tokens.
Content-TypeStringYesMust be application/json
NameTypeRequiredDescription
team_idStringYesThe Team ID to bind the API key to. Retrieved from authorization.
NameTypeRequiredDescription
nameStringNoName of the key to create
descriptionStringNoDescription for the key
expiryStringNoDate-time expiry for the key. Default: 0001-01-01T00:00:00.000Z. Format: ISO 8601
stateStringYesState of the API key. Accepted values: active / inactive
Terminal window
curl -d '{"name": "$NAME", "description": "$DESCRIPTION", "expiry": "$EXPIRY", "state": "$STATE"}' \
-H "X-User-Token: $USER_TOKEN" \
-H "Content-Type: application/json" \
-X POST https://api.massive.app/v1/teams/$TEAM_ID/api_keys

After a successful request, this endpoint returns 201 Created:

{
"created_at": "2021-04-19T16:57:32.683Z",
"description": "This is a sample API key description",
"expiry": "2021-04-24T16:57:32.547Z",
"id": "01F3NH1NRBQWRN7HQDJ2SYGBDH",
"key": "<api-key-value-here>",
"last_request_at": "0001-01-01T00:00:00.000Z",
"name": "Sample API key",
"state": "active",
"updated_at": "2021-04-19T16:57:32.683Z"
}
PropertyDescription
created_atThe datetime that the key was created
descriptionThe key description
expiryThe datetime the key will expire
idThe created API key ID
keyThe actual API key to be used in requests to the MASV API
last_request_atThe last time the key was used
nameThe name of the key
stateState of the API key. Possible values: active, inactive, suspended
updated_atLast time key information was updated

Users can update API keys for any Team, subject to their role.

MethodRoute
PUT/api_keys/{api_key_id}
NameTypeRequiredDescription
X-User-TokenStringYesUser JSON Web Token
Content-TypeStringYesMust be application/json
NameTypeRequiredDescription
api_key_idStringYesThe API key to update. Use the id property, not the key property.
NameTypeRequiredDescription
nameStringNoName of the key
descriptionStringNoDescription for the key
expiryStringNoDate-time expiry. Default: 0001-01-01T00:00:00.000Z. Format: ISO 8601
stateStringYesState of the API key. Accepted values: active / inactive
Terminal window
curl -d '{"name": "$NAME", "description": "$DESCRIPTION", "expiry": "$EXPIRY", "state": "$STATE"}' \
-H "X-User-Token: $USER_TOKEN" \
-H "Content-Type: application/json" \
-X PUT https://api.massive.app/v1/api_keys/$API_KEY_ID

After a successful request, this endpoint returns 200 OK:

{
"created_at": "2021-04-19T16:57:32.683Z",
"description": "This is a sample API key description",
"expiry": "2021-04-24T16:57:32.547Z",
"id": "01F3NH1NRBQWRN7HQDJ2SYGBDH",
"last_request_at": "0001-01-01T00:00:00.000Z",
"name": "Sample API key",
"state": "active",
"updated_at": "2021-04-19T16:57:32.683Z"
}

Authorized users can modify the state of API keys, subject to their role. This is a helper method to quickly toggle a key’s state without fetching and passing the full object.

MethodRoute
PUT/api_keys/{api_key_id}/{action}
NameTypeRequiredDescription
X-User-TokenStringYesUser JSON Web Token
Content-TypeStringYesMust be application/json
NameTypeRequiredDescription
api_key_idStringYesThe API key to update. Use the id property, not the key property.
actionStringYesState to set. Accepted values: active / inactive
Terminal window
curl -H "X-User-Token: $USER_TOKEN" \
-H "Content-Type: application/json" \
-X PUT https://api.massive.app/v1/api_keys/$API_KEY_ID/$ACTION

After a successful request, this endpoint returns 204 No Content with an empty body.

If the key state is suspended, it cannot be activated or deactivated.

Authorized users can delete API keys, subject to their role.

MethodRoute
DELETE/api_keys/{api_key_id}
NameTypeRequiredDescription
X-User-TokenStringYesUser JSON Web Token
Content-TypeStringYesMust be application/json
NameTypeRequiredDescription
api_key_idStringYesThe API key to delete. Use the id property, not the key property.
Terminal window
curl -H "X-User-Token: $USER_TOKEN" \
-H "Content-Type: application/json" \
-X DELETE https://api.massive.app/v1/api_keys/$API_KEY_ID

After a successful request, this endpoint returns 204 No Content with an empty body.

The Team Owner can retrieve a list of all API keys that belong to a given Team.

MethodRoute
GET/teams/{team_id}/api_keys
NameTypeRequiredDescription
X-User-TokenStringYesUser JSON Web Token
Content-TypeStringYesMust be application/json
NameTypeRequiredDescription
team_idStringYesThe Team ID to request API keys from
Terminal window
curl -H "X-User-Token: $USER_TOKEN" \
-H "Content-Type: application/json" \
-X GET https://api.massive.app/v1/teams/$TEAM_ID/api_keys

After a successful request, this endpoint returns 200 OK:

[
{
"created_at": "2021-04-16T20:42:37.659Z",
"description": "This is a sample key",
"expiry": "2021-04-20T20:42:37.000Z",
"id": "01F3E6QN6V9TYCSRCEXB5B9JWR",
"last_request_at": "0001-01-01T00:00:00.000Z",
"name": "Sample key",
"state": "active",
"updated_at": "2021-04-19T10:42:58.221Z"
}
]

API keys can be supplied in the X-API-KEY header on endpoint methods that typically require the user authorization token X-User-Token.

For full package documentation, see Packages.

MethodRoute
GET/teams/{team_id}/packages
Terminal window
curl -H "X-API-KEY: $API_KEY" \
-H "Content-Type: application/json" \
-X GET https://api.massive.app/v1/teams/$TEAM_ID/packages

The following endpoints require X-User-Token:

MethodRoute
GET/teams/{team_id}/api_keys
PUT/api_keys/{api_key_id}
DELETE/api_keys/{api_key_id}
POST/teams/{team_id}/api_keys
PUT/users/{user_id}
POST/users/{user_id}/password
PUT/users/{user_id}/email