Référence API
Authentifiez-vous avec une clé API, créez et finalisez des factures, gérez clients et factures récurrentes. Chaque endpoint ci-dessous est en production.
https://hisab.ma/api/v1L'API Hisab est une API REST JSON servie en HTTPS. Chaque requête est authentifiée par clé API et limitée à votre organisation.
https://hisab.ma/api/v1Les requêtes sont limitées par minute et par clé API. Au-delà, l'API renvoie 429 RATE_LIMIT_EXCEEDED avec un en-tête Retry-After.
| Offre | Requêtes | Clés API |
|---|---|---|
| Professional | 120 req/min | 10 |
| Fiduciaire | 300 req/min | Illimitées |
Chaque réponse indique votre consommation dans ces en-têtes :
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 119
X-RateLimit-Reset: 1780750800Les clés API se créent depuis le tableau de bord : Paramètres, puis Clés API. Vous choisissez les permissions à la création, et le secret complet n'est affiché qu'une seule fois.
Envoyez la clé en jeton Bearer dans l'en-tête Authorization :
curl https://hisab.ma/api/v1/invoices \
-H "Authorization: Bearer hisab_live_***"hisab_live_***Clé de production. Agit sur vos données réelles.
hisab_test_***Clé de test. Même format, pour vos environnements de staging.
Les clés sont stockées hachées (SHA-256) de notre côté et révocables à tout moment depuis le tableau de bord. Un 401 signifie que la clé est absente, invalide ou révoquée :
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}Chaque clé porte une liste explicite de permissions (scopes). Une requête qui exige une permission absente renvoie 403 FORBIDDEN, avec les permissions requises dans les détails de l'erreur.
invoices:readinvoices:writeinvoices:finalizeinvoices:sendinvoices:paymentinvoices:voidinvoices:exportrecurring:readrecurring:writerecurring:deletecustomers:readcustomers:writecustomers:deleteorganization:readorganization:writewebhooks:readwebhooks:writeorganizations:readorganizations:writeorganizations:archiveÀ la création d'une clé, le tableau de bord propose trois ensembles (lecture seule, facturation, accès complet), et vous pouvez toujours choisir les permissions une à une.
Les endpoints de liste acceptent page et per_page (max 100) et renvoient le bloc pagination dans meta :
{
"success": true,
"data": [ ... ],
"meta": {
"pagination": { "total": 128, "page": 1, "perPage": 20, "totalPages": 7 }
}
}Toutes les erreurs partagent la même forme : success vaut false, et error porte un code stable, un message lisible et des détails optionnels par champ. Les codes standards :
VALIDATION_ERROR | 400 |
INVALID_JSON | 400 |
UNAUTHORIZED | 401 |
FORBIDDEN | 403 |
API_DISABLED | 403 |
SUBSCRIPTION_EXPIRED | 403 |
API_TIER_NOT_SUPPORTED | 403 |
ORG_HEADER_REQUIRED | 400 |
ACCOUNT_KEY_REQUIRED | 403 |
ENTITY_CAP_REACHED | 403 |
NOT_FOUND | 404 |
RATE_LIMIT_EXCEEDED | 429 |
INTERNAL_ERROR | 500 |
Hisab signe et envoie un événement à votre endpoint à chaque changement de facture ou de client. Les webhooks se configurent depuis le tableau de bord : Paramètres, puis Webhooks.
invoice.createdinvoice.updatedinvoice.finalizedinvoice.sentinvoice.paidinvoice.voidedcustomer.createdcustomer.updatedcustomer.deletedCréez des brouillons, finalisez-les pour obtenir le numéro officiel, puis suivez envoi, paiement et annulation. Les factures finalisées s'exportent en PDF et XML UBL 2.1.
/api/v1/invoicesRenvoie les factures de votre organisation, les plus récentes d'abord. Filtrez par statut, client ou date d'émission.
invoices:readpage | integerdefault: 1 |
per_page | integerdefault: 20 (max 100) |
order | stringdefault: descascdesc |
status | stringdraftfinalizedsentpaidvoid |
customer_id | uuid |
date_from | date (YYYY-MM-DD) |
date_to | date (YYYY-MM-DD) |
curl https://hisab.ma/api/v1/invoices \
-H "Authorization: Bearer hisab_live_***"/api/v1/invoices/:idRenvoie une facture avec son client, ses lignes et ses totaux.
invoices:readcurl https://hisab.ma/api/v1/invoices/{id} \
-H "Authorization: Bearer hisab_live_***"/api/v1/invoicesCrée un brouillon. Totaux et taxes sont calculés côté serveur à partir des lignes.
invoices:writeinvoice.createdcustomer_idrequired | uuid |
issue_daterequired | date (YYYY-MM-DD) |
due_date | date (YYYY-MM-DD) |
currency | stringdefault: MAD |
payment_terms | string |
notes | string |
internal_notes | string |
items[].descriptionrequired | string |
items[].quantityrequired | number |
items[].unit_pricerequired | number |
items[].tax_rate | numberdefault: 20 |
curl https://hisab.ma/api/v1/invoices \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_2b81fe",
"issue_date": "2026-06-05",
"items": [
{
"description": "Integration services",
"quantity": 8,
"unit_price": 1300,
"tax_rate": 20
}
]
}'/api/v1/invoices/:idModifie un brouillon. Les factures finalisées sont immuables ; l'appel renvoie INVOICE_NOT_EDITABLE.
invoices:writeinvoice.updatedcustomer_id | uuid |
issue_date | date (YYYY-MM-DD) |
due_date | date (YYYY-MM-DD) |
currency | string |
payment_terms | string |
notes | string |
items[].description | string |
items[].quantity | number |
items[].unit_price | number |
items[].tax_rate | numberdefault: 20 |
INVOICE_NOT_EDITABLEcurl https://hisab.ma/api/v1/invoices/{id} \
-X PATCH \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"due_date": "2026-08-05"
}'/api/v1/invoices/:id/finalizeAttribue le numéro séquentiel officiel et verrouille la facture. C'est l'étape d'émission légale.
invoices:finalizeinvoice.finalizedINVOICE_NOT_DRAFTVALIDATION_ERRORcurl https://hisab.ma/api/v1/invoices/{id}/finalize \
-X POST \
-H "Authorization: Bearer hisab_live_***"/api/v1/invoices/:id/sendEnregistre que la facture finalisée a été transmise au client.
invoices:writeinvoice.sentINVALID_STATUS_TRANSITIONcurl https://hisab.ma/api/v1/invoices/{id}/send \
-X POST \
-H "Authorization: Bearer hisab_live_***"/api/v1/invoices/:id/payEnregistre un paiement, avec méthode et référence optionnelles.
invoices:writeinvoice.paidpaid_at | datetime (ISO 8601) |
payment_method | string |
payment_reference | string |
INVALID_STATUS_TRANSITIONcurl https://hisab.ma/api/v1/invoices/{id}/pay \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"payment_method": "bank_transfer",
"payment_reference": "VIR-20260605"
}'/api/v1/invoices/:id/voidAnnule une facture finalisée avec un motif obligatoire. Une facture payée ne peut pas être annulée.
invoices:writeinvoice.voidedreasonrequired | string |
CANNOT_VOID_PAIDALREADY_VOIDEDcurl https://hisab.ma/api/v1/invoices/{id}/void \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"reason": "Duplicate billing"
}'/api/v1/invoices/:id/pdfRenvoie le PDF validé en français, anglais ou arabe. Disponible une fois la facture finalisée.
invoices:exportlocale | stringdefault: frfrenar |
PDF_NOT_AVAILABLEcurl https://hisab.ma/api/v1/invoices/{id}/pdf \
-H "Authorization: Bearer hisab_live_***"/api/v1/invoices/:id/xmlRenvoie le XML UBL 2.1 de la facture finalisée.
invoices:exportXML_NOT_AVAILABLEcurl https://hisab.ma/api/v1/invoices/{id}/xml \
-H "Authorization: Bearer hisab_live_***"Clients B2B et B2C avec identifiants marocains (ICE, RC). L'archivage préserve l'historique de facturation.
/api/v1/customersRenvoie les clients, avec recherche sur le nom, l'email et l'ICE.
customers:readpage | integerdefault: 1 |
per_page | integerdefault: 20 (max 100) |
order | stringdefault: descascdesc |
search | string |
type | stringb2bb2c |
status | stringactiveinactivearchived |
curl https://hisab.ma/api/v1/customers \
-H "Authorization: Bearer hisab_live_***"/api/v1/customers/:idRenvoie un client avec ses coordonnées et son adresse.
customers:readcurl https://hisab.ma/api/v1/customers/{id} \
-H "Authorization: Bearer hisab_live_***"/api/v1/customersLes clients B2B doivent porter leur ICE à 15 chiffres. Les doublons d'ICE sont rejetés au sein de votre organisation.
customers:writecustomer.creatednamerequired | string |
typerequired | stringb2bb2c |
ice | string (15 digits) |
legal_name | string |
rc | string |
email | string |
phone | string |
address.street | string |
address.city | string |
address.postal_code | string |
address.country | stringdefault: MA |
notes | string |
tags | string[] |
curl https://hisab.ma/api/v1/customers \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"name": "MERIT Sarl",
"type": "b2b",
"ice": "001234567000089",
"email": "compta@example.ma"
}'/api/v1/customers/:idMise à jour partielle : n'envoyez que les champs qui changent.
customers:writecustomer.updatedname | string |
type | stringb2bb2c |
ice | string (15 digits) |
email | string |
phone | string |
address | object |
notes | string |
tags | string[] |
status | stringactiveinactivearchived |
curl https://hisab.ma/api/v1/customers/{id} \
-X PATCH \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"email": "finance@example.ma"
}'/api/v1/customers/:idSuppression douce. Le client est archivé et son historique de factures reste intact.
customers:deletecustomer.deletedALREADY_ARCHIVEDcurl https://hisab.ma/api/v1/customers/{id} \
-X DELETE \
-H "Authorization: Bearer hisab_live_***"Des planifications qui génèrent les factures automatiquement, de hebdomadaire à annuelle, avec finalisation et envoi automatiques optionnels.
/api/v1/recurring-invoicesRenvoie les planifications de factures récurrentes. Filtrez par statut, client ou fréquence.
invoices:readpage | integerdefault: 1 |
per_page | integerdefault: 20 (max 100) |
order | stringdefault: descascdesc |
status | stringactivepausedcompletedcancelled |
customer_id | uuid |
frequency | stringweeklybiweeklymonthlyquarterlybiannuallyyearly |
search | string |
curl https://hisab.ma/api/v1/recurring-invoices \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoices/:idRenvoie une planification avec son dernier historique de génération.
invoices:readcurl https://hisab.ma/api/v1/recurring-invoices/{id} \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoicesDéfinit la fréquence, la date de début et les lignes des futures factures.
invoices:writecustomer_idrequired | uuid |
frequencyrequired | stringweeklybiweeklymonthlyquarterlybiannuallyyearly |
start_daterequired | date (YYYY-MM-DD) |
name | string |
interval_count | integer (1-12)default: 1 |
day_of_month | integer (1-28) |
day_of_week | integer (0-6) |
end_date | date (YYYY-MM-DD) |
max_occurrences | integer |
auto_finalize | booleandefault: false |
auto_send | booleandefault: false |
days_until_due | integer (0-365)default: 30 |
currency | stringdefault: MAD |
items[].descriptionrequired | string |
items[].quantityrequired | number |
items[].unit_pricerequired | number |
items[].tax_rate | numberdefault: 20 |
QUOTA_EXCEEDEDcurl https://hisab.ma/api/v1/recurring-invoices \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_2b81fe",
"frequency": "monthly",
"start_date": "2026-07-01",
"auto_finalize": true,
"items": [
{
"description": "Monthly retainer",
"quantity": 1,
"unit_price": 10400,
"tax_rate": 20
}
]
}'/api/v1/recurring-invoices/:idAjuste une planification active ou en pause. Les planifications terminées ou annulées sont en lecture seule.
invoices:writefrequency | stringweeklybiweeklymonthlyquarterlybiannuallyyearly |
end_date | date (YYYY-MM-DD) |
auto_finalize | boolean |
auto_send | boolean |
days_until_due | integer (0-365) |
items | array |
INVALID_STATEcurl https://hisab.ma/api/v1/recurring-invoices/{id} \
-X PUT \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"auto_send": true
}'/api/v1/recurring-invoices/:idSupprime la planification et son historique. Les factures déjà générées ne sont pas affectées.
invoices:writecurl https://hisab.ma/api/v1/recurring-invoices/{id} \
-X DELETE \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoices/:id/generateCrée la prochaine facture immédiatement, en respectant finalisation et envoi automatiques.
invoices:writeissue_date | date (YYYY-MM-DD)default: today |
INVALID_STATECUSTOMER_INACTIVEcurl https://hisab.ma/api/v1/recurring-invoices/{id}/generate \
-X POST \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoices/:id/historyListe les exécutions passées avec les numéros de factures générées et leur statut.
invoices:readlimit | integerdefault: 20 (max 100) |
curl https://hisab.ma/api/v1/recurring-invoices/{id}/history \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoices/:id/pauseSuspend la génération jusqu'à la reprise de la planification.
invoices:writeINVALID_STATEcurl https://hisab.ma/api/v1/recurring-invoices/{id}/pause \
-X POST \
-H "Authorization: Bearer hisab_live_***"/api/v1/recurring-invoices/:id/resumeRelance une planification en pause, éventuellement à partir d'une nouvelle date.
invoices:writenext_run_date | date (YYYY-MM-DD) |
INVALID_STATEcurl https://hisab.ma/api/v1/recurring-invoices/{id}/resume \
-X POST \
-H "Authorization: Bearer hisab_live_***"Le profil de votre organisation, l'état de l'abonnement et les quotas API.
/api/v1/organizationRenvoie identifiants légaux, coordonnées, abonnement et quotas API.
organization:readcurl https://hisab.ma/api/v1/organization \
-H "Authorization: Bearer hisab_live_***"/api/v1/organizationMet à jour identifiants légaux, coordonnées et adresse de facturation.
organization:writelegal_name | string |
ice | string |
rc | string |
if_number | string |
vat_number | string |
phone | string |
email | string |
website | string (URL) |
billing_address | object |
curl https://hisab.ma/api/v1/organization \
-X PATCH \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"phone": "+212 5 22 00 00 01"
}'Gestion des organisations pour les intégrations multi-entités. Ces endpoints exigent une clé de COMPTE (hisab_acct_). Après le provisionnement, opérez chaque entité sur les endpoints habituels en envoyant l'en-tête X-Organization-Id avec la même clé de compte. Un ICE déjà enregistré sur la plateforme ne peut pas être réutilisé, même par un autre compte - il identifie exactement une entité légale.
/api/v1/organizationsRetourne toutes les organisations que possède le propriétaire de la clé. Les entités archivées sont exclues sauf include_archived=true.
organizations:readinclude_archived | booleandefault: false |
ACCOUNT_KEY_REQUIREDcurl https://hisab.ma/api/v1/organizations \
-H "Authorization: Bearer hisab_live_***"/api/v1/organizationsProvisionne une nouvelle entité légale sous votre compte. Le plafond d'entités de votre forfait s'applique ; contactez le support pour l'augmenter.
organizations:writelegal_namerequired | string |
ice | string (15 digits) |
rc | string |
if_number | string |
phone | string |
email | string |
address_street | string |
address_city | string |
address_postal_code | string |
ACCOUNT_KEY_REQUIREDENTITY_CAP_REACHEDcurl https://hisab.ma/api/v1/organizations \
-X POST \
-H "Authorization: Bearer hisab_live_***" \
-H "Content-Type: application/json" \
-d '{
"legal_name": "Filiale Casablanca SARL",
"ice": "002345678000071"
}'/api/v1/organizations/{id}Retourne une organisation possédée. Les identifiants inconnus ou étrangers renvoient 404.
organizations:readACCOUNT_KEY_REQUIREDcurl https://hisab.ma/api/v1/organizations/{id} \
-H "Authorization: Bearer hisab_live_***"/api/v1/organizations/{id}/archiveArchive douce : l'entité est gelée partout (API, tableau de bord, crons) mais rien n'est supprimé. Entièrement réversible.
organizations:archiveACCOUNT_KEY_REQUIREDALREADY_ARCHIVEDcurl https://hisab.ma/api/v1/organizations/{id}/archive \
-X POST \
-H "Authorization: Bearer hisab_live_***"/api/v1/organizations/{id}/restoreAnnule un archivage ; l'entité reprend immédiatement son fonctionnement normal.
organizations:archiveACCOUNT_KEY_REQUIREDNOT_ARCHIVEDcurl https://hisab.ma/api/v1/organizations/{id}/restore \
-X POST \
-H "Authorization: Bearer hisab_live_***"