DPD Trust API Documentation
Start

πŸ” Authentication

All API requests require authentication using your license key or admin key.

License Key Authentication

For merchant endpoints (phone lookup, events, license verify):

Authorization: Bearer YOUR_LICENSE_KEY
X-Country: MA

Admin Key Authentication

For admin endpoints (merchant management, manual blacklist):

X-Admin-Key: YOUR_ADMIN_KEY
X-Country: MA
ℹ️ Note: All requests must include X-Country: MA header. Currently, only Morocco (MA) is supported.

πŸ“± Phone Lookup & Risk Scoring

POST /v1/phone/lookup

Check a phone number's risk score, carrier information, and blacklist status.

Request Headers

HeaderValueRequired
AuthorizationBearer YOUR_LICENSE_KEYRequired
X-CountryMARequired
Content-Typeapplication/jsonRequired

Request Body

ParameterTypeDescriptionRequired
phonestringPhone number (+212661234567 or 0661234567)Required
include_timelinebooleanInclude last 5 events for this phoneOptional

Example Request

curl -X POST https://api.dpd.ma/v1/phone/lookup \
  -H "Content-Type: application/json" \
  -H "X-Country: MA" \
  -H "Authorization: Bearer DPD-STARTER-TEST-002" \
  -d '{
    "phone": "+212661234567",
    "include_timeline": true
  }'

Response

{
  "ok": true,
  "phone": "+212661234567",
  "country": "MA",
  "carrier": { "code": "IAM", "label": "Maroc Telecom" },
  "risk_score": 8,
  "is_blacklisted": false,
  "blacklisted_reason": null,
  "cache_ttl_seconds": 3600,
  "timeline": [
    {
      "event_type": "DELIVERED",
      "order_total": "299.50",
      "currency": "MAD",
      "region": "Casablanca",
      "created_at": "2026-02-01T21:47:49.589Z"
    }
  ]
}

Risk Score Interpretation

ScoreRisk LevelRecommendation
80-100βœ… Low RiskSafe to proceed
50-70⚠️ Medium RiskVerify before proceeding
10-40🚫 High RiskProceed with caution or reject

πŸ“Š Submit Events

POST /v1/phone/lookup (with event_type)

Report order outcomes to improve risk scoring accuracy.

Request Body (Additional Fields)

ParameterTypeDescriptionRequired
event_typestringDELIVERED, PAID_ONLINE, REFUSED_COD, CANCELLED, NO_ANSWER, FRAUD_CONFIRMEDOptional
context.order_totalnumberOrder amountOptional
context.currencystringCurrency code (MAD)Optional
context.regionstringDelivery regionOptional
context.notestringAdditional notesOptional

Example Request

curl -X POST https://api.dpd.ma/v1/phone/lookup \
  -H "Content-Type: application/json" \
  -H "X-Country: MA" \
  -H "Authorization: Bearer DPD-STARTER-TEST-002" \
  -d '{
    "phone": "+212661234567",
    "event_type": "DELIVERED",
    "context": {
      "order_total": 299.50,
      "currency": "MAD",
      "region": "Casablanca"
    }
  }'
βœ… Best Practice: Submit events for all orders to improve scoring accuracy and help the entire merchant community.

πŸ”‘ License Verification

POST /v1/license/verify

Verify your license status and check daily usage limits.

Request Body

ParameterTypeDescriptionRequired
site_urlstringYour registered website URLRequired
emailstringYour registered emailRequired

βš™οΈ Admin Endpoints

ℹ️ Admin Only: These endpoints require X-Admin-Key authentication.

❌ Error Codes

Error CodeHTTP StatusDescription
LICENSE_MISSING401Missing Authorization Bearer token
LICENSE_INVALID403Invalid or inactive license
LICENSE_EXPIRED403Subscription expired, renewal required
COUNTRY_NOT_ALLOWED403X-Country header must be MA
DAILY_LIMIT_REACHED429Daily API usage limit exceeded
INVALID_PAYLOAD400Request body validation failed
ADMIN_UNAUTHORIZED401Missing or invalid X-Admin-Key