Skip to content

Errors

All API errors follow a consistent format and include helpful details.

Error Format

json
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid request parameters",
    "details": [
      {
        "field": "amount",
        "message": "Amount must be positive"
      }
    ]
  },
  "meta": {
    "requestId": "req_abc123"
  }
}

HTTP Status Codes

CodeMeaning
200Success
201Created
400Bad Request
401Unauthorized
403Forbidden
404Not Found
409Conflict
422Unprocessable Entity
429Too Many Requests
500Internal Server Error

Error Codes

Authentication Errors

CodeDescriptionResolution
UNAUTHORIZEDMissing or invalid credentialsCheck API key
FORBIDDENInsufficient permissionsRequest proper scopes
TOKEN_EXPIREDAccess token expiredRefresh the token

Validation Errors

CodeDescriptionResolution
VALIDATION_ERRORInvalid request dataCheck field requirements
INVALID_FORMATMalformed requestVerify JSON format
MISSING_FIELDRequired field missingInclude all required fields

Resource Errors

CodeDescriptionResolution
NOT_FOUNDResource doesn't existCheck the ID
ALREADY_EXISTSDuplicate resourceUse different identifier
CONFLICTState conflictRetry with fresh data

Rate Limit Errors

CodeDescriptionResolution
RATE_LIMITEDToo many requestsWait and retry

Compliance Errors

CodeDescriptionResolution
SHARIAH_VIOLATIONContract violates ShariahReview contract terms
JURISDICTION_ERRORNot allowed in jurisdictionCheck local regulations
COMPLIANCE_FAILEDCompliance check failedReview requirements

Handling Errors

TypeScript/JavaScript

typescript
try {
  const contract = await iof.contracts.create({ ... });
} catch (error) {
  if (error instanceof IOFError) {
    console.error(error.code, error.message);

    if (error.code === "VALIDATION_ERROR") {
      error.details.forEach(d => {
        console.error(`${d.field}: ${d.message}`);
      });
    }
  }
}

Python

python
try:
    contract = iof.contracts.create(...)
except IOFError as error:
    print(f"{error.code}: {error.message}")

    if error.code == "VALIDATION_ERROR":
        for detail in error.details:
            print(f"{detail['field']}: {detail['message']}")

Request IDs

Every response includes a request ID:

json
{
  "meta": {
    "requestId": "req_abc123def456"
  }
}

Include this ID when contacting support.

Next Steps

Licensed under the Apache License 2.0