openapi: 3.1.0 info: title: Bem Buckets Knowledge Graph API version: 1.0.0 description: "Buckets are named partitions of the knowledge graph within an\naccount+environment. Entities, mentions, and relations are scoped to a\nbucket so a single account+environment can host multiple isolated graphs\n— for example one per data source or workspace.\n\nEvery account+environment has exactly one **default** bucket, used by\nunscoped flows. The default bucket can be renamed but never deleted.\n\nUse these endpoints to create, list, fetch, rename, and delete buckets:\n\n- **`POST /v3/buckets`** creates a non-default bucket.\n- **`GET /v3/buckets`** lists buckets with cursor pagination\n (`startingAfter` / `endingBefore` over `bucketID`).\n- **`PATCH /v3/buckets/{bucketID}`** updates `name` and/or `description`.\n- **`DELETE /v3/buckets/{bucketID}`** soft-deletes a bucket. A non-empty\n bucket is rejected with `409 Conflict` unless `?cascade=true` is\n passed; the default bucket can never be deleted." servers: - url: https://api.bem.ai description: US Region API variables: {} - url: https://api.eu1.bem.ai description: EU Region API variables: {} security: - API Key: [] tags: - name: Knowledge Graph description: "Read the cross-document knowledge graph — the canonical entities and the\ndirected relations between them that the Parse pipeline populates when\n`linkAcrossDocuments` is enabled.\n\n- **`GET /v3/entities/{id}/relations`** returns the inbound and outbound\n edges incident to one entity, split by direction. Supports\n `direction`, an exact `relationType` filter, and cursor pagination over\n edges. A merged-away entity id transparently resolves to its surviving\n canonical entity.\n- **`GET /v3/knowledge-graph`** returns the graph as `{ nodes, edges }`,\n paginating over edges. The `nodes` for a page are the distinct endpoint\n entities of that page's edges (both endpoints of every edge are\n included). Filter with `type[]`, `since`, and `search`; an edge is\n returned only when both of its endpoints survive the entity filters.\n\nBoth endpoints take an optional `bucket` (`bkt_...`) to scope the read to\na single bucket; omit it for the unscoped account+environment view." paths: /v3/entities/{id}/relations: get: operationId: v3-get-entity-relations summary: Get an Entity's Relations parameters: - name: id in: path required: true description: Entity public ID (`ent_...`). A merged-away id transparently resolves to the surviving entity. schema: type: string - name: direction in: query required: false description: Which edges to return relative to the entity. Defaults to `both`. schema: type: string enum: - inbound - outbound - both explode: false - name: relationType in: query required: false description: Exact-match filter on the relation label. schema: type: string explode: false - name: limit in: query required: false description: Maximum number of edges to return (default 50, max 200). schema: type: integer format: int32 explode: false - name: cursor in: query required: false description: 'Cursor: return edges whose KSUID sorts after this value.' schema: type: string explode: false - name: bucket in: query required: false description: 'Optional bucket public ID (`bkt_...`) to scope the read to one bucket. Omit for the unscoped (all account+environment) view.' schema: type: string explode: false responses: '200': description: The request has succeeded. content: application/json: schema: $ref: '#/components/schemas/EntityRelationsResponseV3' tags: - Knowledge Graph /v3/knowledge-graph: get: operationId: v3-get-knowledge-graph summary: Retrieve the Knowledge Graph parameters: - name: nodeID in: query required: false description: 'Center the graph on this entity (`ent_...`) and only return the subgraph within `maxDepth` hops of it; every node then carries its `depth` (hops from the center, center = 0). Omit for the uncentered whole-graph view. `rootNodeID` and `focusNodeID` are accepted as aliases.' schema: type: string explode: false - name: maxDepth in: query required: false description: 'Maximum hops from the center node. Only meaningful with `nodeID`. Defaults to 2 and is clamped down to a system maximum (5).' schema: type: integer format: int32 explode: false - name: limit in: query required: false description: Maximum number of edges per page (default 50, max 200). schema: type: integer format: int32 explode: false - name: cursor in: query required: false description: 'Cursor: return edges whose KSUID sorts after this value.' schema: type: string explode: false - name: type in: query required: false description: 'Restrict to entities of these types. An edge is returned only when BOTH of its endpoints survive the type filter.' schema: type: array items: type: string explode: false - name: since in: query required: false description: Only edges created at/after this RFC 3339 timestamp. schema: type: string format: date-time explode: false - name: search in: query required: false description: 'Case-insensitive substring match on canonical names. Both endpoints of an edge must match for the edge (and its nodes) to be returned.' schema: type: string explode: false - name: bucket in: query required: false description: 'Optional bucket public ID (`bkt_...`) to scope the read to one bucket. Omit for the unscoped (all account+environment) view.' schema: type: string explode: false responses: '200': description: The request has succeeded. content: application/json: schema: $ref: '#/components/schemas/KnowledgeGraphResponseV3' tags: - Knowledge Graph components: schemas: EntityRelationsResponseV3: type: object required: - inbound - outbound properties: inbound: type: array items: $ref: '#/components/schemas/InboundRelationV3' description: Edges pointing at the queried entity. outbound: type: array items: $ref: '#/components/schemas/OutboundRelationV3' description: Edges pointing away from the queried entity. nextCursor: type: string description: 'Opaque cursor for the next page of edges, or absent on the last page. Pass it back as `cursor`.' description: Response body for `GET /v3/entities/{id}/relations`. GraphEdgeV3: type: object required: - sourceId - targetId - relationType - mentionCount properties: sourceId: type: string description: Source entity public id (`ent_...`). targetId: type: string description: Target entity public id (`ent_...`). relationType: type: string description: Free-form relation label. mentionCount: type: integer format: int32 description: How many times this edge has been observed. description: One directed edge between two entities, addressed by their public ids. RelatedEntityV3: type: object required: - id - canonical - type - depth properties: id: type: string description: Stable public identifier for the entity (`ent_...`). canonical: type: string description: Canonical (most descriptive) surface form of the entity. type: type: string description: Effective entity type. depth: type: integer format: int32 description: 'Hops from the queried entity. This endpoint returns direct relations, so this is 1 (a self-loop''s far end is the queried entity itself, 0).' description: 'A compact view of an entity sitting on the far end of a relation edge — the stable public id, the canonical name, and the effective type. The full entity is fetched separately via the entity detail / File System endpoints.' OutboundRelationV3: type: object required: - relationType - targetEntity - mentionCount - firstSeenAt properties: relationType: type: string description: Free-form relation label (e.g. `author_of`, `affiliated_with`). targetEntity: allOf: - $ref: '#/components/schemas/RelatedEntityV3' description: The entity at the head of the edge. mentionCount: type: integer format: int32 description: How many times this edge has been observed across parsed documents. firstSeenAt: type: string format: date-time description: First-seen timestamp of the edge (RFC 3339). description: One edge pointing AWAY from the queried entity (it is the source). GraphNodeV3: type: object required: - id - canonical - type - mentionCount - depth properties: id: type: string description: Stable public identifier for the entity (`ent_...`). canonical: type: string description: Canonical (most descriptive) surface form. type: type: string description: Effective entity type. mentionCount: type: integer format: int32 description: Total mentions of this entity across all parsed documents. depth: type: integer format: int32 description: 'Hops from the center node when the request centers the graph on one entity (`nodeID`). The center is depth 0. When the request is uncentered (no `nodeID`), this is 0 for every node.' description: One entity node in the knowledge graph. KnowledgeGraphResponseV3: type: object required: - nodes - edges properties: nodes: type: array items: $ref: '#/components/schemas/GraphNodeV3' description: Distinct endpoint entities of the returned edge page. edges: type: array items: $ref: '#/components/schemas/GraphEdgeV3' description: The page of edges. nextCursor: type: string description: 'Opaque cursor for the next page of edges, or absent on the last page. Pass it back as `cursor`.' description: 'Response body for `GET /v3/knowledge-graph`. Pagination is over edges; `nodes` are the distinct endpoint entities of the returned edge page (both endpoints of every edge are included).' InboundRelationV3: type: object required: - relationType - sourceEntity - mentionCount - firstSeenAt properties: relationType: type: string description: Free-form relation label (e.g. `author_of`, `affiliated_with`). sourceEntity: allOf: - $ref: '#/components/schemas/RelatedEntityV3' description: The entity at the tail of the edge. mentionCount: type: integer format: int32 description: How many times this edge has been observed across parsed documents. firstSeenAt: type: string format: date-time description: First-seen timestamp of the edge (RFC 3339). description: One edge pointing AT the queried entity (some other entity is the source). securitySchemes: API Key: type: apiKey in: header name: x-api-key description: Authenticate using API Key in request header