SafeKeepAPI Reference

SafeKeep API Reference

Version: v1 Base URL: https://api.safekeep.africa/v1


Authentication

All /v1 endpoints require a platform API key issued during onboarding.

Authorization: Bearer <API_KEY>

API keys are provisioned via the platform:create script. Each key is scoped to a single platform. Keys are hashed before storage — if lost, a new key must be generated.


POST /v1/check-identity

Check the risk profile of an entity. Call this before allowing a new user, seller, merchant, borrower, or agent to register, list, transact, or apply.

SafeKeep normalizes and hashes all identity inputs server-side. Raw values are never persisted.

Request Body

{
  "entityId": "your-internal-id-123",
  "phone": "+2348031234567",
  "email": "[email protected]",
  "name": "John Doe",
  "bankAccount": "0123456789",
  "businessReg": "RC1234567",
  "nin": "12345678901",
  "bvn": "12345678901",
  "context": "registration"
}
Field Type Required Notes
entityId string Yes Your internal identifier for this entity
phone string No +234 and 00234 prefixes normalized automatically
email string No Lowercased and trimmed before hashing
name string No Lowercased, trimmed, whitespace collapsed before hashing
bankAccount string No Nigerian bank account number
businessReg string No CAC registration number
nin string No National Identification Number — requires user consent (NDPR)
bvn string No Bank Verification Number — requires user consent (CBN/NDPR)
context enum No Where in your flow this check is called. See context values below.

At least one of phone, email, name, bankAccount, businessReg, nin, or bvn is required. More signals produce more accurate identity clustering.

On entityId and registration timing: SafeKeep is designed to be called before a user is written to your database — so you can block bad actors at the gate rather than cleaning them up after the fact. This requires your entityId to exist before the DB insert.

Recommended: generate the ID in application code (e.g. crypto.randomUUID()) before inserting. Use that UUID as both your DB primary key and the entityId passed to SafeKeep. If the check returns block, discard the UUID and never insert the row.

If your platform uses DB-generated IDs (auto-increment integers, sequences), you have two options: (1) use a stable pre-existing signal as the entityId — phone or email from the registration form exists before any DB insert and is unique per platform; (2) insert the user as status: pending, check SafeKeep with the resulting ID, then activate or hard-delete depending on the outcome.

Consent notice: You are responsible for obtaining explicit user consent before submitting nin or bvn. Both are regulated under the CBN BVN Framework and NDPR. Submitting these fields implies consent has been obtained.

context values

Value Use when
registration New entity account creation
listing Entity posts a listing or activates inventory
merchant_onboarding Merchant or agent onboarding to a payment or lending platform
loan_application Entity submits a loan or credit application
transaction Real-time transaction gate

Context is optional but recommended. It enables stricter thresholds for high-risk flows (see Risk Governance) and is captured in audit logs for analytics.

Response

{
  "riskScore": 72,
  "riskLevel": "high",
  "signals": [
    {
      "type": "cluster_fraud_history",
      "severity": "high",
      "description": "Linked identity cluster has 2 prior validated fraud reports."
    },
    {
      "type": "cross_platform_identity_linkage",
      "severity": "high",
      "description": "Identity cluster spans 2 platforms."
    }
  ],
  "explanation": {
    "tokenMatchCount": 2,
    "fraudReportCount": 2,
    "clusterMemberCount": 3,
    "clusterId": "2f130b2b-831d-4caa-97b5-0188c38d95d2",
    "platformCount": 2,
    "externalPlatformCount": 1,
    "highestSignalTier": 2,
    "confidenceLevel": "high",
    "signalAgeDecayApplied": false
  },
  "recommendedAction": "block"
}

Response Fields

riskScore number, 10–95 Composite risk score. 10 = clean first-seen entity. 95 = maximum (cap reserved for future signal layers).

riskLevel "low" | "medium" | "high"

Level Meaning Default action
low No fraud history, no cluster linkage Allow
medium Linked to an existing identity cluster, no confirmed fraud Manual review
high Confirmed fraud history or cross-platform identity match Block

recommendedAction "allow" | "manual_review" | "block" Derived from riskLevel and context. Integrate this field directly into your decision flow.

signals array Active risk signals for this entity. Empty array for clean entities. Each signal includes a description explaining the finding in plain language.

explanation object Audit-grade breakdown of the risk decision.

Field Type Meaning
tokenMatchCount number Identity tokens that matched existing entities not already owned by this entity
fraudReportCount number Total fraud reports attached to this entity's identity cluster
clusterMemberCount number Number of entities sharing this identity cluster
clusterId string UUID of the identity cluster assigned to this entity
platformCount number Distinct platforms represented in this cluster
externalPlatformCount number Platforms other than yours in this cluster
highestSignalTier number Strength of the linking signal: 1 = phone/email/name, 2 = bank account/business reg, 3 = NIN/BVN
confidenceLevel "low" | "medium" | "high" Confidence in the identity linkage. High = Tier 3 signals or 3+ platforms.
signalAgeDecayApplied boolean True if Tier 1 fraud linkage was discounted due to signal age >18 months (Nigerian phone recycling mitigation)
compromiseHistoryCount number Number of identity theft reports linked to this entity's tokens. Non-zero means the entity may be a victim of identity misuse — not a fraudster.

Signals

identity_cluster_linkage — severity: medium This entity shares at least one identity token with entities already in the SafeKeep network. They have been merged into a shared identity cluster.

cross_platform_identity_linkage — severity: high This entity's identity cluster spans multiple platforms. The same identity has appeared on one or more external platforms. Triggers high risk escalation automatically.

cluster_fraud_history — severity: high This entity's identity cluster has prior validated fraud reports. Fraud weight is inherited by all cluster members regardless of which platform reported it.

stale_signal_warning — severity: low Fraud linkage is based on Tier 1 signals (phone/email/name) older than 18 months. The risk score has been reduced — Nigerian number recycling may apply. Present when signalAgeDecayApplied: true.

context_escalation — severity: high The context field changed the risk outcome. The base signals alone would not have triggered high risk, but the context (e.g. loan_application) applies stricter thresholds.

identity_compromise_history — severity: medium Identity tokens linked to this entity appear in one or more identity theft reports. This entity may be a victim of identity misuse rather than a fraudster. Verify identity carefully before proceeding. This signal does not add to riskScore or trigger high risk — it prevents low and forces a minimum of manual_review. Present when compromiseHistoryCount > 0.

Risk Governance

riskLevel is derived from the strength and combination of signals present — fraud history, cross-platform recurrence, cluster size, and the confidence of the linking signals. High risk is triggered when strong fraud signals or cross-platform recurrence is detected.

Context-aware thresholds

Certain contexts apply stricter thresholds. loan_application is evaluated more conservatively than registration — the bar for blocking is lower. transaction applies real-time gates appropriate for payment flows.

Signal confidence and age

Signals are weighted by the strength of the identity tokens that produced them. Higher-tier signals (NIN/BVN) produce stronger linkage confidence than phone or email alone. Older signals may be weighted differently to account for identity recycling patterns in the Nigerian market. When this applies, signalAgeDecayApplied: true is returned and a stale_signal_warning signal is included.


POST /v1/report-incident

Report a validated incident against one of your entities. The event strengthens the entity's identity cluster and updates risk signals across the network.

Platform isolation: You can only report incidents on entities registered under your platform. Attempting to report against an entity belonging to another platform returns 404 ENTITY_NOT_FOUND. This is enforced at the database level.

An entity must have been checked via POST /v1/check-identity at least once before an incident can be reported against them.

Request Body

{
  "entityId": "your-internal-id-123",
  "incidentCategory": "deposit_scam",
  "severity": "high",
  "evidenceType": "confirmed_internal_review",
  "caseReference": "CASE-2024-001"
}
Field Type Required Notes
entityId string Yes Must belong to your platform
incidentCategory enum Yes See below
severity enum Yes low, medium, high, or critical. See below.
evidenceType enum Yes See below
caseReference string Yes Your internal case ID. Duplicate submissions (same entity + case) are silently deduplicated.

incidentCategory

Value Description
deposit_scam Entity collected payment and did not deliver
fake_device_listing Listing was fabricated — fake photos or non-existent product
impersonation Entity impersonating another person or brand
repeat_ban_evasion Entity creating new accounts after a ban
misrepresentation Material misrepresentation of product condition or specifications
loan_fraud False loan application or intent to default
account_takeover Unauthorized access to another entity's account
synthetic_identity Fabricated identity combining real and fake credentials
investment_scam Ponzi scheme, fake investment, or capital flight fraud
rental_fraud Fake landlord, agent, or property listing
identity_theft Entity's identity was stolen and used by a fraudster. Routes to a separate handler — marks tokens as compromised without adding fraud weight to the entity. See Identity Theft Reports.

evidenceType

Value Description
confirmed_internal_review Your trust and safety team has reviewed and confirmed
user_report_validated User report validated through your internal process
bank_reversal_confirmed Bank-initiated reversal confirmed (Nigerian bank transfer context)
platform_dispute_resolved Platform ruled in the buyer/victim's favour after formal investigation

severity guidance

Value Use when
low Single report, low confidence, no confirmed loss
medium Validated by internal review, no confirmed financial loss
high Confirmed financial harm or bank reversal
critical Repeat offender, coordinated or organized fraud

Response

{
  "status": "accepted",
  "message": "Incident recorded"
}

Duplicate submissions (same entityId + caseReference) return accepted without creating a duplicate event.


POST /v1/report-incidents

Submit up to 100 incidents in a single call. Each item uses the same schema as POST /v1/report-incident. Items are processed independently — a failure on one item does not affect the others.

Use this for bulk onboarding of historical fraud data, overnight fraud sweeps, or any flow where your platform generates incidents in batches.

Request Body

{
  "incidents": [
    {
      "entityId": "your-internal-id-001",
      "incidentCategory": "deposit_scam",
      "severity": "high",
      "evidenceType": "confirmed_internal_review",
      "caseReference": "CASE-2024-001"
    },
    {
      "entityId": "your-internal-id-002",
      "incidentCategory": "rental_fraud",
      "severity": "medium",
      "evidenceType": "platform_dispute_resolved",
      "caseReference": "CASE-2024-002"
    }
  ]
}
Field Type Required Notes
incidents array Yes 1 to 100 items. Each item follows the same schema as POST /v1/report-incident.

Response

{
  "accepted": 2,
  "failed": 1,
  "results": [
    { "entityId": "your-internal-id-001", "caseReference": "CASE-2024-001", "status": "accepted" },
    { "entityId": "your-internal-id-002", "caseReference": "CASE-2024-002", "status": "accepted" },
    { "entityId": "your-internal-id-999", "caseReference": "CASE-2024-003", "status": "failed", "error": "ENTITY_NOT_FOUND" }
  ]
}
Field Type Meaning
accepted number Count of items successfully recorded
failed number Count of items that could not be processed
results array Per-item outcome in the same order as the request
results[].status "accepted" | "failed" Outcome for this item
results[].error string Present only on failed items. Same error codes as the single endpoint.

Failed items should be logged and retried after resolving the underlying issue (e.g. the entity must be checked via check-identity before a report can be filed against them).


Identity Theft Reports

When an entity reports that their identity was stolen and used by someone else, use incidentCategory: "identity_theft" on POST /v1/report-incident. This routes to a separate handler with different semantics:

{
  "entityId": "victim-entity-123",
  "incidentCategory": "identity_theft",
  "severity": "high",
  "evidenceType": "confirmed_internal_review",
  "caseReference": "CASE-2024-IDT-001"
}

severity and evidenceType are accepted for schema consistency but are not applied in identity theft processing — no fraud weight is assigned.

Response

{
  "status": "accepted",
  "message": "Identity theft report recorded — tokens marked as compromised"
}

POST /v1/retract-report

Retract a previously filed incident. Use this when your internal review determines a report was filed in error.

Scope: Retracts only your platform's contribution. If other platforms have independently reported the same identity cluster, their reports remain untouched. This prevents coordinated retraction from erasing genuine network-wide fraud evidence.

Platform isolation: You can only retract incidents you filed. Attempting to retract another platform's report returns 404 INCIDENT_NOT_FOUND.

Request Body

{
  "entityId": "your-internal-id-123",
  "caseReference": "CASE-2024-001"
}
Field Type Required Notes
entityId string Yes Must belong to your platform
caseReference string Yes The same caseReference used when filing the incident

Response

{
  "status": "accepted",
  "message": "Incident retracted"
}

Returns 404 INCIDENT_NOT_FOUND if no matching incident exists for your platform with the given case reference.


POST /v1/identity-history

Look up the incident history for an identity cluster without creating or modifying any data. Use this for manual review flows — after a check-identity returns medium or high risk, call this endpoint to fetch the full incident trail before making a decision.

Unlike check-identity, this endpoint has no side effects: it does not create entities, upsert tokens, or write audit events.

Request Body

{
  "phone": "+2348031234567",
  "email": "[email protected]",
  "name": "John Doe",
  "bankAccount": "0123456789"
}

At least one identity signal is required. entityId is not needed — this is a pure identity lookup, not a registration event.

Response

{
  "found": true,
  "clusterId": "2f130b2b-831d-4caa-97b5-0188c38d95d2",
  "entityCount": 2,
  "platformCount": 2,
  "totalIncidents": 3,
  "incidents": [
    {
      "category": "deposit_scam",
      "severity": "high",
      "reportedAt": "2024-03-15T10:30:00Z",
      "ownPlatform": false
    },
    {
      "category": "loan_fraud",
      "severity": "critical",
      "reportedAt": "2024-04-01T08:00:00Z",
      "ownPlatform": true,
      "caseReference": "CASE-2024-001"
    }
  ]
}
Field Type Meaning
found boolean false if no matching identity tokens exist in the network
clusterId string Identity cluster UUID. null if entity exists but has no cluster yet.
entityCount number Total entities in the cluster
platformCount number Distinct platforms represented in the cluster
totalIncidents number Total confirmed incidents attached to this cluster
incidents[].ownPlatform boolean true if your platform filed this report
incidents[].caseReference string Only present when ownPlatform: true

Privacy note: External platform reports show category, severity, and reportedAt only. Case references and reporter identity are never exposed across platform boundaries.

Returns found: false cleanly when no matching identity tokens exist — not an error.


Webhooks

SafeKeep delivers a signed HTTP POST to your configured webhook endpoint whenever check-identity returns riskLevel: "high". Delivery is fire-and-forget from your API call's perspective — the response to your check-identity request is never delayed.

Configure your webhook endpoint from your platform portal at https://api.safekeep.africa/platform.

Delivery

Method: POST Content-Type: application/json Headers:

Header Description
X-SafeKeep-Signature sha256=<hmac-hex> — HMAC-SHA256 of the raw request body, signed with your webhook secret
X-SafeKeep-Timestamp ISO 8601 timestamp of when the event was generated
User-Agent SafeKeep-Webhooks/1.0

Payload

{
  "event": "risk.high",
  "timestamp": "2024-04-01T10:30:00.000Z",
  "platformId": "your-platform-id",
  "entityId": "your-internal-entity-id",
  "context": "registration",
  "riskScore": 85,
  "riskLevel": "high",
  "recommendedAction": "block",
  "signals": [
    {
      "type": "cross_platform_identity_linkage",
      "severity": "high",
      "description": "Identity cluster spans 2 platforms."
    }
  ],
  "explanation": {
    "fraudReportCount": 1,
    "clusterMemberCount": 2,
    "platformCount": 2,
    "externalPlatformCount": 1,
    "confidenceLevel": "medium"
  }
}

Signature Verification

Always verify the signature before acting on a webhook delivery.

const crypto = require('crypto');

function verifyWebhook(rawBody, signatureHeader, webhookSecret) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', webhookSecret)
    .update(rawBody)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signatureHeader),
    Buffer.from(expected),
  );
}

// Express example
app.post('/webhooks/safekeep', express.raw({ type: 'application/json' }), (req, res) => {
  const sig = req.headers['x-safekeep-signature'];
  if (!verifyWebhook(req.body, sig, process.env.SAFEKEEP_WEBHOOK_SECRET)) {
    return res.status(401).send('Invalid signature');
  }
  const event = JSON.parse(req.body);
  // handle event.event === 'risk.high'
  res.sendStatus(200);
});

Use express.raw() (not express.json()) on your webhook route — HMAC is computed over the raw bytes. Parsing to JSON first changes the body and breaks signature verification.

Retry Behaviour

SafeKeep retries failed deliveries up to 3 times with exponential backoff (1s, 5s, 20s). A delivery is considered failed if your endpoint returns a non-2xx status or does not respond within 10 seconds. After 3 failed attempts, the event is dropped and logged server-side.

Respond with any 2xx status as quickly as possible. Process the payload asynchronously if needed.


Error Codes

HTTP Code Meaning
400 INVALID_INPUT Request body failed validation. Check the message field for which field failed.
401 UNAUTHORIZED Missing or malformed Authorization header
401 INVALID_API_KEY API key not recognized
404 ENTITY_NOT_FOUND Entity ID not found under your platform. The entity must be checked via check-identity before fraud can be reported.
429 RATE_LIMIT_EXCEEDED Rate limit exceeded. Default: 100 requests per minute per platform key. Response includes Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.
500 INTERNAL_ERROR Contact SafeKeep support

Integration Pattern

SafeKeep is designed to be called at multiple checkpoints in your entity lifecycle. Each checkpoint serves a different purpose.

Checkpoint 1 — Registration

Call check-identity when an entity account is created.

{
  "entityId": "entity-123",
  "phone": "+2348012345678",
  "email": "[email protected]",
  "context": "registration"
}
riskLevel Recommended action
low Allow registration
medium Allow, flag for manual review
high Block registration

Checkpoint 2 — Listing or Transaction

Call check-identity again when an entity posts a listing, activates inventory, or initiates a transaction.

{
  "entityId": "entity-123",
  "phone": "+2348012345678",
  "email": "[email protected]",
  "context": "listing"
}

Risk is not static. A entity that registered cleanly may have been flagged on another platform by the time they post their first listing.

Checkpoint 3 — Loan Application

For lending flows, pass context: "loan_application" and include NIN/BVN where consent has been obtained:

{
  "entityId": "applicant-456",
  "phone": "+2348031234567",
  "nin": "12345678901",
  "bvn": "12345678901",
  "context": "loan_application"
}

The loan_application context applies stricter thresholds — any fraud history triggers block. NIN/BVN signals produce confidenceLevel: "high".

Reporting Confirmed Incidents

When your internal review confirms fraud or an abuse incident, submit it promptly:

{
  "entityId": "entity-123",
  "incidentCategory": "deposit_scam",
  "severity": "high",
  "evidenceType": "confirmed_internal_review",
  "caseReference": "CASE-2024-001"
}

Every confirmed event immediately protects all connected platforms from the same identity cluster.

End-to-End Example

Day 1  Entity registers on Platform A
       → POST /v1/check-identity (context: registration)
       → riskLevel: low → allowed

Day 2  Same entity scams a buyer on Platform B
       → Platform B: POST /v1/report-incident
       → Cluster receives fraud weight (severity: high)

Day 3  Entity creates a listing on Platform A
       → POST /v1/check-identity (context: listing)
       → riskLevel: high
       → signals: [cross_platform_identity_linkage, cluster_fraud_history]
       → listing blocked

Platform A never needed to detect the fraud themselves. The network did it.


Notes