In cases where the API responds with an error code, the response body will contain additional information about the error.
JSON general error responses will look like this:

{
  "errors": [
    {
      "type": 401,
      "message": "Not authorized."
    }
  ]
}

Error responses to resource-specific operations will associate error messages to resource attributes, like this:

{
  "errors": [
    {
      "type": "InvalidInputSchema",
      "message": "The task input does not match the project schema"
    }
  ]
}

With asynchronous task creation, Sama Platform's requests to the callback URL will not only include the message and type of each error but will also include the request data and the task id.

{
  "success": false,
  "errors": [
    {
      "task_id": "5ebccdc1c49dae54721567a1",
      "type": 400,
      "message": "Invalid seeded output name(s): Bad_Output",
      "request_data": {
        "project_id": 1,
        "questions": {
          "x": 10,
          "y": 30
        },
        "default_answers": {
          "Bad_Output": "40"
        },
        "priority": 3
      }
    }
  ]
}

HTTP Response Codes

Depending on the requested operation, the Samahub API will respond with one of the following HTTP status codes.

200

Success

Request was processed successfully

201

Created

A new resource was created successfully.

202

Accepted

A new resource was accepted for asynchronous creation. We will post the result of the resource creation to the creation callback URL.

302

Redirect

We are redirecting you to a resource. The body of this response often contains a message.

400

Invalid Format

You failed to pass one or more required parameters. See body of response for more information.

401

Unauthorized

Authorization failed, check your key. If your key is correct, contact Sama Project Manager to enable API access to your project.

404

Resource Not Found

We could not find the resource (i.e. object) you were looking for, or you do not have access to it.

405

Method Not Allowed

The method you are using (GET, POST, PUT, DELETE) is not available from this URL

406

Not Acceptable

The format you requested is not available.

409

Duplicate

Task with primary key has already been received.

422

Unprocessable Entity

There was an error creating a resource.

500

Internal Server Error

This could be the result of improperly formatted JSON.

503

Service Unavailable

The project is not in an ‘Active’ state on the Sama Platform.