{
 "openapi": "3.1.0",
 "info": {
  "title": "Customer · Credit Profile (CRM)",
  "version": "20261030b",
  "description": "The limit, what it is made of, what happens when it is reached, and what security is held against it. Reviewed on its own cycle by different people."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "customer-credit": {
    "type": "object",
    "required": [
     "account_id"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "account_id": {
      "type": "string",
      "format": "uuid",
      "description": "Account"
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id"
     },
     "credit_limit": {
      "type": "string",
      "format": "decimal",
      "description": "Credit limit"
     },
     "currency": {
      "type": "string",
      "description": "Currency"
     },
     "order_limit": {
      "type": "string",
      "format": "decimal",
      "description": "Single order limit"
     },
     "includes_open_orders": {
      "type": "boolean",
      "description": "Open orders count towards it"
     },
     "includes_undelivered": {
      "type": "boolean",
      "description": "Undelivered goods count towards it"
     },
     "credit_rating": {
      "type": "string",
      "description": "External rating"
     },
     "rating_agency": {
      "type": "string",
      "description": "Rating agency"
     },
     "rating_date": {
      "type": "string",
      "format": "date",
      "description": "Rating date"
     },
     "internal_score": {
      "type": "string",
      "format": "decimal",
      "description": "Internal score"
     },
     "risk_category": {
      "type": "string",
      "description": "Risk category",
      "enum": [
       "low",
       "moderate",
       "elevated",
       "high",
       "prohibited"
      ]
     },
     "on_limit_breach": {
      "type": "string",
      "description": "When the limit is reached",
      "enum": [
       "allow",
       "warn",
       "hold",
       "reject"
      ]
     },
     "is_on_credit_hold": {
      "type": "boolean",
      "description": "On credit hold"
     },
     "hold_reason": {
      "type": "string",
      "description": "Hold reason"
     },
     "hold_placed_on": {
      "type": "string",
      "format": "date",
      "description": "Hold placed on"
     },
     "hold_placed_by": {
      "type": "string",
      "format": "uuid",
      "description": "Hold placed by"
     },
     "has_credit_insurance": {
      "type": "boolean",
      "description": "Credit insured"
     },
     "insurer": {
      "type": "string",
      "description": "Insurer"
     },
     "insured_amount": {
      "type": "string",
      "format": "decimal",
      "description": "Insured amount"
     },
     "has_guarantee": {
      "type": "boolean",
      "description": "Guaranteed"
     },
     "guarantee_expires": {
      "type": "string",
      "format": "date",
      "description": "Guarantee expires"
     },
     "requires_prepayment": {
      "type": "boolean",
      "description": "Prepayment required"
     },
     "requires_letter_of_credit": {
      "type": "boolean",
      "description": "Letter of credit required"
     },
     "reviewed_on": {
      "type": "string",
      "format": "date",
      "description": "Last reviewed"
     },
     "reviewed_by": {
      "type": "string",
      "format": "uuid",
      "description": "Reviewed by"
     },
     "next_review_on": {
      "type": "string",
      "format": "date",
      "description": "Next review"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "effective_from": {
      "type": "string",
      "format": "date",
      "description": "In force from"
     },
     "effective_to": {
      "type": "string",
      "format": "date",
      "description": "Until"
     },
     "xf_text_1": {
      "type": "string",
      "description": "Xf text 1",
      "readOnly": true
     },
     "xf_text_2": {
      "type": "string",
      "description": "Xf text 2",
      "readOnly": true
     },
     "xf_text_3": {
      "type": "string",
      "description": "Xf text 3",
      "readOnly": true
     },
     "xf_text_4": {
      "type": "string",
      "description": "Xf text 4",
      "readOnly": true
     },
     "xf_text_5": {
      "type": "string",
      "description": "Xf text 5",
      "readOnly": true
     },
     "xf_num_1": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 1",
      "readOnly": true
     },
     "xf_num_2": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 2",
      "readOnly": true
     },
     "xf_num_3": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 3",
      "readOnly": true
     },
     "xf_date_1": {
      "type": "string",
      "format": "date",
      "description": "Xf date 1",
      "readOnly": true
     },
     "xf_date_2": {
      "type": "string",
      "format": "date",
      "description": "Xf date 2",
      "readOnly": true
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "readOnly": true
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Updated at",
      "readOnly": true
     },
     "updated_by": {
      "type": "string",
      "format": "uuid",
      "description": "Updated by",
      "readOnly": true
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/crm/customer-credit": {
   "get": {
    "summary": "list customer-credit",
    "operationId": "list_customer_credit_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create customer-credit",
    "operationId": "create_customer_credit_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/customer-credit/{id}": {
   "get": {
    "summary": "get customer-credit",
    "operationId": "get_customer_credit_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change customer-credit",
    "operationId": "change_customer_credit_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete customer-credit",
    "operationId": "delete_customer_credit_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/crm/customer-credit/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_customer_credit_0_6",
    "description": "Body keys: overrides, preview, withLines",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}