SonicJs has a common token based authentication system allowing you login, obtain a valid token and supply that token to subsequent api requests.

Access Control

  1. To authorize via the API post to /v1/auth/login with the email and password in the body

      "email": "[email protected]",
      "password": "password123"
  2. The API will return a bearer token

      "bearer": "eo0t9q52njemo83rm1qktr6kwjh8zu5o3vma1g6j"
  3. Then add that bearer token to the Authorization header on future requests

    const url =
    const data = {
      data: {
        title: 'Test Post Update',
    const requestOptions = {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        Authorization: 'Bearer eo0t9q52njemo83rm1qktr6kwjh8zu5o3vma1g6j',
      body: JSON.stringify(data),
    fetch(url, requestOptions)
  4. You can now access the current user profile data at /v1/auth/user