{
  "openapi": "3.1.0",
  "info": {
    "title": "BMA Marketplace host API",
    "version": "2026-11-13",
    "description": "For host platforms that run a BMA marketplace inside their own product: sync customers, read what they have, and show vendors’ screens in your own menus. Guide: https://bma.botmodepro.com/docs/developer/host-api.html"
  },
  "servers": [
    {
      "url": "https://bma.botmodepro.com/mp/v1/host"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "hostKey": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "summary": "Your host and its marketplaces",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "$ref": "#/components/schemas/Me"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/catalog": {
      "get": {
        "summary": "What a marketplace sells (the storefront's cards)",
        "parameters": [
          {
            "name": "marketplace",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Marketplace code; default: your first active marketplace"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers": {
      "get": {
        "summary": "Your customers, oldest first",
        "parameters": [
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Customer"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}": {
      "get": {
        "summary": "One customer",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "$ref": "#/components/schemas/Customer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "put": {
        "summary": "Create or update a customer organization",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 128,
                    "description": "Required the first time"
                  },
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "meta": {
                    "type": "object",
                    "description": "Any JSON object up to 4 KB, kept for you"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "customer": {
                              "$ref": "#/components/schemas/Customer"
                            },
                            "created": {
                              "type": "boolean"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}/entitlements": {
      "get": {
        "summary": "What one customer has",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Entitlement"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}/subscriptions": {
      "get": {
        "summary": "One customer's subscriptions in your marketplaces",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Subscription"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}/orders": {
      "get": {
        "summary": "One customer's orders in your marketplaces",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          },
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Order"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/entitlements": {
      "get": {
        "summary": "What all your customers have",
        "parameters": [
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Entitlement"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/subscriptions": {
      "get": {
        "summary": "All your customers' subscriptions",
        "parameters": [
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Subscription"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/orders": {
      "get": {
        "summary": "All your customers' orders",
        "parameters": [
          {
            "$ref": "#/components/parameters/updated_since"
          },
          {
            "$ref": "#/components/parameters/after"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "array",
                              "items": {
                                "$ref": "#/components/schemas/Order"
                              }
                            },
                            "next_after": {
                              "type": [
                                "integer",
                                "null"
                              ]
                            },
                            "server_time": {
                              "type": "string",
                              "format": "date-time",
                              "description": "BMA's clock when this list was read (ISO 8601 with offset). Send the first page's value as updated_since on your next sync."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}/menu": {
      "get": {
        "summary": "Vendor screens for your own navigation",
        "description": "The nav_items of the customer's live, set-up products in your marketplaces.",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/MenuProduct"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/customers/{external_org_id}/launch": {
      "post": {
        "summary": "A signed address of one screen for one of your users",
        "parameters": [
          {
            "$ref": "#/components/parameters/external_org_id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subscription_id",
                  "item",
                  "user"
                ],
                "properties": {
                  "subscription_id": {
                    "type": "integer"
                  },
                  "item": {
                    "type": "string"
                  },
                  "user": {
                    "type": "object",
                    "required": [
                      "id"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "maxLength": 64,
                        "pattern": "^[A-Za-z0-9._:@-]+$"
                      },
                      "name": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email"
                      },
                      "admin": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "api_version": {
                          "type": "string",
                          "example": "2026-11-13"
                        },
                        "data": {
                          "$ref": "#/components/schemas/Launch"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer mph_…"
      },
      "hostKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-BMA-Host-Key",
        "description": "If a proxy drops Authorization"
      }
    },
    "parameters": {
      "external_org_id": {
        "name": "external_org_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$"
        },
        "description": "Your own id for the organization (the org_id of the embed sign-in token)"
      },
      "updated_since": {
        "name": "updated_since",
        "in": "query",
        "schema": {
          "type": "string",
          "example": "2026-06-01 00:00:00"
        },
        "description": "Only rows changed at or after this time: YYYY-MM-DD, YYYY-MM-DD HH:MM[:SS] (BMA's time zone), or ISO 8601 with Z or an offset (converted). Best: the server_time of your previous sync. Unreadable values are ignored."
      },
      "after": {
        "name": "after",
        "in": "query",
        "schema": {
          "type": "integer"
        },
        "description": "next_after of the previous page"
      },
      "limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 100
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "const": false
                },
                "message": {
                  "type": "string"
                },
                "data": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "field": {
                      "type": "string"
                    },
                    "retry_after": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Me": {
        "type": "object",
        "properties": {
          "api_version": {
            "type": "string"
          },
          "host": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "marketplaces": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "currency": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "external_org_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "meta": {
            "type": [
              "object",
              "null"
            ]
          },
          "updated_at": {
            "type": "string"
          },
          "created_at": {
            "type": "string"
          }
        }
      },
      "Entitlement": {
        "type": "object",
        "properties": {
          "external_org_id": {
            "type": "string"
          },
          "marketplace": {
            "type": "string"
          },
          "product": {
            "type": "string"
          },
          "product_name": {
            "type": "string"
          },
          "product_type": {
            "type": "string"
          },
          "plan": {
            "type": "string"
          },
          "subscription_id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "onboarding",
              "pending",
              "trialing",
              "active",
              "past_due",
              "suspended",
              "cancelled",
              "ended"
            ]
          },
          "entitlement": {
            "type": "string",
            "enum": [
              "on",
              "off",
              "provisioning",
              "suspended",
              "failed"
            ]
          },
          "active": {
            "type": "boolean",
            "description": "Act on this: the customer can use the product now"
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ]
          },
          "cancel_at_period_end": {
            "type": "boolean"
          },
          "updated_at": {
            "type": "string"
          }
        }
      },
      "Subscription": {
        "type": "object",
        "additionalProperties": true
      },
      "Order": {
        "type": "object",
        "additionalProperties": true
      },
      "MenuProduct": {
        "type": "object",
        "description": "A customer's product with the vendor's screens (nav_items). Show them as Vendor › Category › Product.",
        "properties": {
          "marketplace": {
            "type": "string"
          },
          "subscription_id": {
            "type": "integer"
          },
          "vendor_name": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "description": "the product's first category in that marketplace, or \"Other\""
          },
          "product_name": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9-]{1,47}$"
                },
                "title": {
                  "type": "string"
                },
                "icon": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "an mdi- icon name"
                },
                "parent": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "another item's key"
                },
                "open": {
                  "type": "string",
                  "enum": [
                    "iframe",
                    "tab"
                  ]
                }
              }
            }
          }
        }
      },
      "Launch": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "signed https address; expires in about two minutes: open it straight away"
          },
          "mode": {
            "type": "string",
            "enum": [
              "none",
              "vendor_sso",
              "jwt"
            ]
          },
          "open": {
            "type": "string",
            "enum": [
              "iframe",
              "tab"
            ]
          },
          "title": {
            "type": "string"
          },
          "product": {
            "type": "string"
          }
        }
      }
    }
  }
}
