# Configuration in KDB-X DB Service

_This page describes how to target a specific assembly in the KDB-X DB Service, and how to export an assembly configuration._

## Assembly configuration

The DB Service is configured using an **assembly** — a YAML document that defines the assembly name and labels, table schemas, stream bus settings, storage mounts, and service elements such as Storage Manager tiers and DAP mounts.

You can export the configuration of an assembly. This is useful for reviewing the current configuration, or as a reference when preparing a new deployment.

Refer to the [API spec](api/dbservice.html) for detailed reference, including examples for all APIs. Sample notebooks demonstrating API usage are bundled with the [DB Service repo](https://github.com/KxSystems/kdbx-db-service) on GitHub.

## Assembly selection

The DB Service can be configured with more than one assembly. Each assembly has its own independent set of tables, so a request always targets a single assembly.

- **Single-assembly deployments** — the assembly is selected automatically, and the `assembly` parameter is optional.

- **Multi-assembly deployments** — identify the target assembly with the `assembly` query parameter, for example `GET /api/v0/tables?assembly=marketdata-emea`. The parameter is required.

Assembly selection applies to the [table management](manage-tables.md), [import](import.md), and [assembly export](#export-assembly) APIs.

The following conditions return `400`:

| **Condition** | **Error** |
|---|---|
| Parameter omitted when the service is configured with more than one assembly | `assembly must be specified when the service is configured with more than one assembly` |
| Name does not match a configured assembly | `unknown assembly: marketdata-emea` |

## Export assembly

The export assembly endpoint is [`GET /api/v0/config/assembly`](api/dbservice.html#tag/Configuration/operation/exportAssembly). The response body is the assembly YAML document itself, not a JSON wrapper.

### Example export assembly

=== "q"
    ```q
    // Return the assembly YAML as a string
    assemblyYaml:session.exportAssembly[]

    // Save the assembly YAML to a file
    session.exportAssembly([path:"assembly.yaml"])
    ```

=== "Python"
    ```python
    # Return the assembly YAML as a string
    assembly_yaml = session.export_assembly()
    print(assembly_yaml)

    # Save the assembly YAML to a file
    session.export_assembly(filename="assembly.yaml")
    ```

=== "REST"
    ```bash
    curl -X GET "http://localhost:8080/api/v0/config/assembly" \
        -H "Accept: application/yaml"
    ```

## Next steps

- Refer to the [DB Service repo](https://github.com/KxSystems/kdbx-db-service) for further details and examples.
- See the [REST APIs](api/dbservice.html) for reference.
- Learn more about [table management](manage-tables.md) and [query](query.md).
