Error & Status Codes

alfred status codes throughout our API products

Status Codes:

alfred uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.).

Some 4xx errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.

Error Types

Status Code Status ResponseDescription

202

ACCEPTED

Everything worked as expected.

404

NOT FOUND

The requested resource doesn't exist.


Error Handling:

Here is an example of making a request to my-info endpoint with a required property in the body missing:

https://api-dev-services.alfredpay.app/api/v1/third-party-service/my-info

bashCopy codecurl --request POST \
  --url https://api-dev-services.alfredpay.app/api/v1/third-party-service/my-info \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: Insomnia/2023.5.7' \
  --header 'api-key: alfredpay.fbm1lIK_Pdi7G1buBEMXyIcp4CPX6a38' \
  --header 'api-secret: s8MhbbRKrWDIilV~nBtpDgnKqpTRwYyv' \
  --data '{
   "type": "in",
   "currency": "USDC",
   "user": "0x0DD967bb17aB6cfaA4Aafdaed70d8f1DaFf22222",
   "chain" : "polygon"
}
'

The error response would be:

jsonCopy code{
  "statusCode": 422,
  "message": "A logic validation has not been fulfilled",
  "reasons": [
    {
      "message": "balance should not be empty",
      "path": "balance",
      "validation": "isNotEmpty"
    },
    {
      "message": "balance must be a number conforming to the specified constraints",
      "path": "balance",
      "validation": "isNumber"
    }
  ],
  "code": "VALIDATION_ERROR"
}

Now, this would be an example of making the same request with an incorrect api-key.

bashCopy codecurl --request POST \
  --url https://api-dev-services.alfredpay.app/api/v1/third-party-service/my-info \
  --header 'Content-Type: application/json' \
  --header 'User-Agent: Insomnia/2023.5.7' \
  --header 'api-key: 3rr0r8' \
  --header 'api-secret: s8MhbbRKrWDIilV~nBtpDgnKqpTRwYyv' \
  --data '{
   "type": "in",
   "currency": "USDC",
   "user": "0x0DD967bb17aB6cfaA4Aafdaed70d8f1DaFf22222",
   "chain" : "polygon"
}
'

The response would be:

jsonCopy code{
  "statusCode": 400,
  "message": "Bad credentials"
}

The same response above would occur if the api-secret is passed incorrectly.

These same error responses apply to all other endpoints.


https://api-dev-services.alfredpay.app/api/v1/third-party-service/login-sof-kyc

In the following curl, we will omit the firstname field in the body.

Example curl:

bashCopy codecurl --request POST \
  --url https://api-dev-services.alfredpay.app/api/v1/third-party-service/login-sof-kyc \
  --header 'Content-Type: application/json' \
  --header 'api-key: alfredpay.fbm1lIK_Pdi7G1buBEMXyIcp4CPX6a38' \
  --header 'api-secret: s8MhbbRKrWDIilV~nBtpDgnKqpTRwYyv' \
  --data '{
  "initial_transaction": "3b49a3e3-76fd-42ca-85c1-6c405620947d",
  "phonenumber": "+346",
  "email": "Name@gmail.com",
  "lastname": "Jane",
  "address": "Doe",
  "country": "CHL",
  "city": "Santiago",
  "zipcode": 1033,
  "birthday": "1987-04-12"
}'

The response is:

jsonCopy code{
  "statusCode": 422,
  "message": "A logic validation has not been fulfilled",
  "reasons": [
    {
      "message": "firstname must be a string",
      "path": "firstname",
      "validation": "isString"
    },
    {
      "message": "firstname should not be empty",
      "path": "firstname",
      "validation": "isNotEmpty"
    }
  ],
  "code": "VALIDATION_ERROR"
}

Now, in this example, lastname will not be passed, which is a required property.

bashCopy codecurl --request POST \
  --url https://api-dev-services.alfredpay.app/api/v1/third-party-service/login-sof-kyc \
  --header 'Content-Type: application/json' \
  --header 'api-key: alfredpay.fbm1lIK_Pdi7G1buBEMXyIcp4CPX6a38' \
  --header 'api-secret: s8MhbbRKrWDIilV~nBtpDgnKqpTRwYyv' \
  --data '{
  "initial_transaction": "3b49a3e3-76fd-42ca-85c1-6c405620947d",
  "phonenumber": "+346",
  "email": "Name@gmail.com",
  "address": "Montalban II",
  "country": "CHL",
  "city": "Santiago",
  "zipcode": 1033,
  "birthday": "1987-04-12"
}'

And the response will be:

jsonCopy code{
  "statusCode": 422,
  "message": "A logic validation has not been fulfilled",
  "reasons": [
    {
      "message": "firstname must be a string",
      "path": "firstname",
      "validation": "isString"
    },
    {
      "message": "firstname should not be empty",
      "path": "firstname",
      "validation": "isNotEmpty"
    },
    {
      "message": "lastname must be a string",
      "path": "lastname",
      "validation": "isString"
    },
    {
      "message": "lastname should not be empty",
      "path": "lastname",
      "validation": "isNotEmpty"
    }
  ],
  "code": "VALIDATION_ERROR"
}

https://api-dev-services.alfredpay.app/api/v1/third-party-service/payment-method

Here's an example of trying to execute the endpoint with an invalid token, this often can be an expired token:

bashCopy codecurl --request POST \
  --url https://api-dev-services.alfredpay.app/api/v1/third-party-service/payment-method \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IkB0cmluaWFndWlycmUiLCJzdWIiOjMsImlhdCI6MTY5ODQ0MjY0NCwiZXhwIjoxNjk4NDQyNzA0fQ.b1E71Cv8p_k41v9pMHhfmFYhLyYBx2Og5I55ea1EN_k' \
  --header 'Content-Type: application/json' \
  --header 'api-key: fbm1lIK_Pdi7G1buBEMXyIcp4CPX6a38' \
  --header 'api-secret: s8MhbbRKrWDIilV~nBtpDgnKqpTRwYyv' \
  --data '{
  "initial_transaction": "f5fe0353-f3c3-4543-be80-170ebfbaa380",
  "phonenumber": "+346",
  "email": "Sample@gmail.com",
  "fullname": "Jane Doe",
  "address": "Montalban II",
  "country": "CHL",
  "city": "Santiago",
  "countrywithdraw": "GTM"
}'

The response would be:

jsonCopy code{
	"statusCode": 400,
	"message": "Bad credentials"
}

When an internal server error occurs, the response would be:

jsonCopy code{
	"statusCode": 500,
	"message": "Internal server error"
}

These same error handling responses apply to all other endpoints.

Last updated