Search documentation

Type a word or phrase to search documentation.

    Reference

    HTTP API

    Use the gateway URL supplied for your environment to query and update Legra over HTTP. Requests need access to the selected workspace.

    The gateway publishes its endpoint definitions at /openapi.json and an interactive reference at /swagger-ui/. Open these paths on your gateway URL; they are not documentation-site routes.

    Authentication and selection

    Use the credentials issued for your integration. API-key requests include:

    X-Legra-Api-Key: <api-token>
    

    Authenticated session integrations must follow the session requirements in the gateway's API reference. Do not copy browser credentials into shared scripts.

    Choose the workspace and branch explicitly:

    X-Legra-Workspace: <workspace-identifier>
    X-Legra-Branch-Name: main
    

    Use X-Legra-Branch-Id instead of X-Legra-Branch-Name when selecting by full branch identifier. Supplying both branch headers is an error. SPARQL requests also accept ?workspace=<workspace>; the workspace header takes precedence.

    Query

    Send a SPARQL query as the request body:

    POST /api/v1/sparql/query
    X-Legra-Api-Key: <api-token>
    X-Legra-Workspace: <workspace-identifier>
    X-Legra-Branch-Name: main
    Content-Type: application/sparql-query
    Accept: application/sparql-results+json
    
    SELECT ?graph ?s ?p ?o WHERE {
      GRAPH ?graph { ?s ?p ?o }
    } LIMIT 10
    

    The endpoint also accepts a URL-encoded form with a query field. Use application/x-www-form-urlencoded for that representation.

    Update

    Updates require write permission. For example:

    POST /api/v1/sparql/update
    X-Legra-Api-Key: <api-token>
    X-Legra-Workspace: <workspace-identifier>
    X-Legra-Branch-Name: review
    Content-Type: application/sparql-update
    
    INSERT DATA {
      GRAPH <https://example.org/people> {
        <https://example.org/alice> <https://example.org/name> "Alice" .
      }
    }
    

    Check the HTTP status and response body before treating a change as successful.

    Graph Store Protocol

    Use /graph-store to work with graph contents. Include your authentication and workspace selection on these requests too.

    RequestOperation
    GET /graph-store?graph=<encoded-iri>Retrieve a named graph
    PUT /graph-store?graph=<encoded-iri>Replace its contents
    POST /graph-store?graph=<encoded-iri>Add statements
    DELETE /graph-store?graph=<encoded-iri>Delete the graph
    GET /graph-store?defaultRetrieve the default graph

    URL-encode the graph IRI. For triple-format writes, choose exactly one of ?graph= or ?default. Quad formats, N-Quads and TriG, carry graph names in the payload and must not include either selector.

    A replacement request might contain:

    PUT /graph-store?graph=https%3A%2F%2Fexample.org%2Fpeople
    X-Legra-Api-Key: <api-token>
    X-Legra-Workspace: <workspace-identifier>
    Content-Type: text/turtle
    
    @prefix ex: <https://example.org/> .
    ex:alice ex:name "Alice" .
    

    Formats and errors

    Set Content-Type to describe the request and Accept to choose a response. For SELECT and ASK, use application/sparql-results+json. For graph results, request text/turtle or application/n-triples.

    Graph uploads accept Turtle, N-Triples, RDF/XML, N-Quads, and TriG with their corresponding RDF media types. An unsupported request media type returns 415; an unsupported response representation returns 406.

    For an error, inspect the response message and verify the credentials, workspace, branch selector, and statement. See the gateway's OpenAPI reference for endpoint-specific parameters and responses.