> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sahlfinancial.com/llms.txt
> Use this file to discover all available pages before exploring further.

# KYB Morocco: onboard and ICE check

> Read a Moroccan company's file (Modèle J, attestation IF, manager's CIN) and get a decision with checks, or check an ICE number.

Two calls for Moroccan companies. Both are open to every plan, use a key from your workspace and take the environment from `X-Sahl-Environment` (`sandbox` by default).

| Endpoint | Scope | Billed |
| - | - | - |
| `POST /v1/kyb/ma/onboard` | `kyb:onboard` | 1 document per file sent. The CIN front and back count as one. |
| `POST /v1/kyb/ma/ice-check` | `kyb:ice` | No. No document is read. |

Production calls need your workspace to be approved for Production API calls: until then they answer 403 `production_api_not_approved`. See [Go live](https://docs.sahlfinancial.com/go-live.md#partner-document-apis). Each key is limited to 60 calls a minute on these routes (429 `rate_limit_exceeded` with `Retry-After`).

## Onboard a company

`POST /v1/kyb/ma/onboard` takes `multipart/form-data`. The documents are read in parallel and the answer is synchronous. Plan for a few seconds and a 60-second client timeout.

| Part | Required | What |
| - | - | - |
| `modele_j` | yes | The Modèle J (extrait du registre du commerce) or the Modèle 7 (certificat d'immatriculation). |
| `cin` | yes | The manager's CIN (CNIE), front. |
| `cin_back` | no | The CIN's back. Its MRZ check digits are then verified. |
| `attestation_if` | recommended | The DGI attestation d'identifiant fiscal. Without it the file is read but always goes to `manual_review`: there is nothing to cross-check the ICE against. |
| `reference` | no | Your id for the client, 1 to 64 characters of `A-Z a-z 0-9 _ . : -`. Echoed back and sent in the webhook. |
| `environment` | no | `sandbox` or `production`, as a form field. If it disagrees with `X-Sahl-Environment` the call is refused (422 `environment_conflict`). |

Files: PDF (native or scanned), JPEG, PNG, TIFF or WebP, up to 30 MB each, up to 12 pages for a PDF. The content is checked against the declared type.

```bash cURL theme={"dark"}
curl -X POST https://app.sahlfinancial.com/api/v1/kyb/ma/onboard \
  -H "Authorization: Bearer $SAHL_API_KEY" \
  -H "X-Sahl-Environment: sandbox" \
  -F modele_j=@specimen-modele-j.pdf \
  -F attestation_if=@specimen-attestation-if.pdf \
  -F cin=@specimen-cin-recto.png \
  -F cin_back=@specimen-cin-verso.png \
  -F reference=client-42
```

```javascript JavaScript theme={"dark"}
import { openAsBlob } from "node:fs";

const form = new FormData();
form.append("modele_j", await openAsBlob("specimen-modele-j.pdf"), "specimen-modele-j.pdf");
form.append("attestation_if", await openAsBlob("specimen-attestation-if.pdf"), "specimen-attestation-if.pdf");
form.append("cin", await openAsBlob("specimen-cin-recto.png"), "specimen-cin-recto.png");
form.append("cin_back", await openAsBlob("specimen-cin-verso.png"), "specimen-cin-verso.png");
form.append("reference", "client-42");

const res = await fetch("https://app.sahlfinancial.com/api/v1/kyb/ma/onboard", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SAHL_API_KEY}`,
    "X-Sahl-Environment": "sandbox",
  },
  body: form,
});
const kyb = await res.json();
console.log(kyb.decision, kyb.reasons);
```

```python Python theme={"dark"}
import os, requests

files = {
    "modele_j": open("specimen-modele-j.pdf", "rb"),
    "attestation_if": open("specimen-attestation-if.pdf", "rb"),
    "cin": open("specimen-cin-recto.png", "rb"),
    "cin_back": open("specimen-cin-verso.png", "rb"),
}
res = requests.post(
    "https://app.sahlfinancial.com/api/v1/kyb/ma/onboard",
    headers={
        "Authorization": f"Bearer {os.environ['SAHL_API_KEY']}",
        "X-Sahl-Environment": "sandbox",
    },
    files=files,
    data={"reference": "client-42"},
    timeout=60,
)
kyb = res.json()
print(kyb["decision"], kyb["reasons"])
```

The files above are the Sandbox [specimens](https://docs.sahlfinancial.com/guides/sandbox-specimens.md): the Sandbox reads specimen documents only.

### The answer

Abridged, with specimen data:

```json theme={"dark"}
{
  "kyb_id": "6f1c0000-0000-4000-8000-000000000001",
  "environment": "sandbox",
  "reference": "client-42",
  "document_kind": "modele_j",
  "company": {
    "raison_sociale": "SPECIMEN TRADING SARL",
    "forme_juridique": "SARL",
    "ice": "001234567000062",
    "rc_number": "123456",
    "tribunal": "Casablanca",
    "siege_social": "12 Rue Exemple, Casablanca",
    "capital": "100000.00",
    "date_creation": "2019-03-15",
    "activite": "Négoce de fournitures de bureau",
    "gerants": [
      {"nom": "ALAMI", "prenom": "Mohamed", "nom_ar": "محمد العلمي", "cin": "BK123456", "qualite": "co-gérant"}
    ]
  },
  "tax": {"if_number": "12345678"},
  "manager": {
    "nom": "ALAMI", "prenom": "Mohamed", "nom_ar": "محمد العلمي",
    "cin_number": "BK123456", "date_naissance": "1985-06-12", "expiry": "2031-01-01"
  },
  "checks": [
    {"key": "documents_read", "status": "pass", "message": "Every document sent was read."},
    {"key": "ice_registry", "status": "skipped", "message": "Not verified at the registry: Morocco has no public ICE / RC registry API."}
  ],
  "gerant_match": {"matched": true, "gerant_index": 0, "score": 0.95, "method": "exact", "reason": null},
  "decision": "auto_ok",
  "reasons": [],
  "screening": {"status": "pass", "matches": []},
  "company_record": "stored",
  "evidence": {
    "company.ice": {"status": "valid", "confidence": 0.92, "evidence": "validator", "source": "modele_j", "corroborated_by": ["attestation_if"]}
  },
  "documents": [
    {"role": "modele_j", "sent": true, "read": true, "reader_unavailable": false, "fields_read": 12}
  ],
  "reader_unavailable": false,
  "billing": {"documents_billed": 3, "environment": "sandbox"},
  "latency_ms": 2900
}
```

| Field | Meaning |
| - | - |
| `kyb_id` | Id of this call. Also in the `kyb.completed` webhook. |
| `document_kind` | `modele_j` or `modele_7`, what you sent as `modele_j`. |
| `company`, `tax`, `manager` | What was read. A value is absent or `null` when it was not on the document. |
| `checks` | The list of checks. Each has a `key`, a `status` (`pass`, `fail`, `warn` or `skipped`) and a `message`; some carry a `code`. `skipped` means nothing could be proven, never a pass. |
| `gerant_match` | Whether the CIN holder is one of the company's gérants, and how: `method` is `cin_number`, `exact`, `skeleton`, `fuzzy`, `transliteration` or `none`. |
| `decision` | `auto_ok` or `manual_review`. |
| `reasons` | Why the file needs a person. Empty for `auto_ok`. |
| `screening` | The company, every gérant and the CIN holder, screened against the sanctions and PEP lists Sahl loads. `matches` lists the hits. A party that could not be screened is `skipped`, never "no match". |
| `evidence` | Per value: `status` (`valid`, `needs_review` or `missing`), `confidence`, and what backs it. |
| `company_record` | `stored`, `updated`, `not_stored` or `conflict`. See [ICE check](#check-an-ice). |
| `reader_unavailable` | True when a document could not be read because of a problem on Sahl's side. A document not read is not billed. |
| `billing` | `documents_billed` and the environment. |

The check keys are: `documents_read`, `ice_format`, `ice_checksum`, `ice_cross_document` (the ICE on the Modèle J equals the ICE on the attestation), `ice_registry`, `company_name_agreement`, `rc_format`, `modele_j_recency`, `if_format`, `cin_mrz`, `cin_format`, `cin_expiry`, `gerant_match` and `screening`. `ice_registry` is always `skipped`: Morocco has no public ICE or RC registry API, so Sahl does not query one and does not invent registry data.

### How the decision is made

`auto_ok` only when every required check passed and nothing failed: the documents were read, the ICE, IF and RC are well formed, the ICE on the Modèle J equals the ICE on the attestation, both name the same company, the CIN is not expired, the CIN holder is one of the gérants and the sanctions and PEP screening ran clear. Otherwise `manual_review`, with `reasons`. A check can carry a `code` saying why a person must look. A `warn` with a `code` blocks `auto_ok`. Plain warnings without a code, such as a Modèle J older than three months or a CIN expiring within 30 days, are reported and do not block it.

Codes you may see on a check or a reason:

| Code | On | When |
| - | - | - |
| `non_discriminant` | `gerant_match` | The holder's name matches a gérant, but a near twin of the name would match as well. |
| `ambiguous_match` | `gerant_match` | The holder's name matches two or more gérants. |
| `cin_name_conflict` | `gerant_match` | A gérant carries the holder's CIN number under a name that does not match. |
| `screening_not_run` | `screening` | The screening could not run, or a name had nothing searchable. |
| `screening_potential_match` | `screening` | A list entry scores 0.88 or more. |
| `screening_match` | `screening` | A sanctions entry scores 0.99 or more. |
| `ice_key_invalid` | `ice_checksum` | The ICE check key does not match. |
| `rc_tribunal_unknown` | `rc_format` | The RC tribunal is not a Moroccan court. |
| `name_partial` | `company_name_agreement` | One name has distinctive words the other lacks. |
| `legal_form_mismatch` | `company_name_agreement` | Same words, another legal form. |

A masculine and a feminine name (Karim and Karima) are never treated as one name. Arabic and Latin spellings of a name are matched.

### Evidence

A value is `valid` only with proof: a check digit (MRZ), the ICE's key, or two documents that agree. A value that only has the right shape (a CIN, IF, CNSS or RC format) is `needs_review`, with a confidence of at most 0.85. A value only the reader saw is `needs_review`, at most 0.70.

### Errors

| Status | `detail.code` | Cause |
| - | - | - |
| 400 | `empty_file` | A part is empty. |
| 400 | (message) | Unsupported file type, or the content does not match the declared type. |
| 403 | `production_api_not_approved`, `production_requires_paid_plan`, `work_email_required`, `production_trial_ended` | Production rules. See [Go live](https://docs.sahlfinancial.com/go-live.md#partner-document-apis). |
| 413 | `document_too_long` | A PDF has more than 12 pages. |
| 413 | (message) | A file over 30 MB. |
| 422 | `invalid_reference`, `invalid_environment`, `environment_conflict` | Bad input. |
| 422 | `sandbox_specimen_required` | A real document in the Sandbox. `documents` names the parts that are not specimens. See [Sandbox specimens](https://docs.sahlfinancial.com/guides/sandbox-specimens.md). |
| 429 | `rate_limit_exceeded` | More than 60 calls a minute with one key. |
| 429 | `sandbox_daily_cap_reached` | Sandbox fair use: 200 documents a day per workspace. |
| 429 | `usage_limit_reached` | The plan's monthly document quota in Production. |
| 503 | `reader_unavailable` | No document could be read. Nothing is billed. Retry after the `Retry-After` header. |

The quota is checked before anything is read, so a refused call costs nothing.

## Check an ICE

`POST /v1/kyb/ma/ice-check` takes JSON:

| Field | Required | Rules |
| - | - | - |
| `ice` | yes | Up to 40 characters. Spaces, dots and dashes are ignored. |
| `raison_sociale` | no | Up to 255 characters. Compared with the name Sahl already knows for this ICE. |
| `reference` | no | Your id, same rules as above. |
| `environment` | no | `sandbox` or `production`. |

```bash cURL theme={"dark"}
curl -X POST https://app.sahlfinancial.com/api/v1/kyb/ma/ice-check \
  -H "Authorization: Bearer $SAHL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ice": "001 234 567 000 062", "raison_sociale": "Specimen Trading", "reference": "client-42"}'
```

```javascript JavaScript theme={"dark"}
const res = await fetch("https://app.sahlfinancial.com/api/v1/kyb/ma/ice-check", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SAHL_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ ice: "001 234 567 000 062", raison_sociale: "Specimen Trading", reference: "client-42" }),
});
const check = await res.json();
```

```python Python theme={"dark"}
import os, requests

check = requests.post(
    "https://app.sahlfinancial.com/api/v1/kyb/ma/ice-check",
    headers={"Authorization": f"Bearer {os.environ['SAHL_API_KEY']}"},
    json={"ice": "001 234 567 000 062", "raison_sociale": "Specimen Trading", "reference": "client-42"},
).json()
```

```json theme={"dark"}
{
  "check_id": "0c1d0000-0000-4000-8000-000000000004",
  "environment": "sandbox",
  "ice": "001234567000062",
  "format_valid": true,
  "format_message": null,
  "checksum_ok": true,
  "checksum_advisory": "The ICE check key rule is not officially published; a mismatch is never a rejection, but sends an onboarding file to manual review (ice_key_invalid).",
  "registry_status": "non_verifie_au_registre",
  "registry_note": "Morocco has no public ICE / RC registry API: this ICE was not verified at OMPIC or the DGI.",
  "known": {
    "raison_sociale": "SPECIMEN TRADING SARL",
    "address": "12 Rue Exemple, Casablanca",
    "source": "sahl_kyb_reads",
    "last_seen_at": "2026-11-23T09:12:44+00:00"
  },
  "raison_sociale_agrees": true
}
```

| Field | Meaning |
| - | - |
| `format_valid` | The ICE has 15 digits and is not a placeholder. `format_message` says why when it is not. |
| `checksum_ok` | The commonly used check key. The rule is not officially published, so `false` is never a rejection. In an onboard file it sends the file to review (`ice_key_invalid`). `null` when the format is invalid. |
| `registry_status` | Always `non_verifie_au_registre`. The ICE was not verified at a registry. |
| `known` | What your own earlier onboard calls read for this ICE in the same environment, or `null`. It is never another customer's data. `source` is always `sahl_kyb_reads`. |
| `raison_sociale_agrees` | `true` only when the names agree. A partial name, or another legal form, is `false`. `null` when there is nothing to compare. |

`known` is filled from onboard calls only: Sahl keeps, per workspace and environment, the ICE, company name and address of a file that was `auto_ok` with a valid ICE key read alike on both documents. A later file naming another company never overwrites the stored name: the call answers `company_record: "conflict"` and Sahl reviews it. Nothing about the manager (name, CIN, birth date) is kept by the onboard call.

In the Sandbox the ICE check reads no document, so it checks the format of any ICE. The specimen ICE is `001234567000062`.

## Webhooks

Both calls send an event, if you have an endpoint subscribed (see [Webhook endpoints](https://docs.sahlfinancial.com/guides/webhook-endpoints.md)). Payloads carry ids, your reference, the decision and the keys of checks that did not pass. They never carry a company name, an ICE, a CIN or a person's name.

| Event | When | Payload (besides `event`, `event_id`, `occurred_at`, `tenant_id`) |
| - | - | - |
| `kyb.completed` | After each onboard call | `kyb_id`, `reference`, `environment`, `decision`, `checks_not_passed`, `gerant_matched`, `reader_unavailable` |
| `ice.checked` | After each ICE check | `check_id`, `reference`, `environment`, `format_valid`, `known` (boolean), `registry_status` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.