> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ferrum.thalamiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# System-Level Operations

> Execute operations at the system level

## System-Level Operations

Execute FHIR operations at the system level. These operations affect the entire server, not specific resources.

<ParamField path="operation" type="string" required>
  The operation name (e.g., `$validate`, `$everything`, `$export`)
</ParamField>

## Endpoint

```
GET /fhir/$:operation
POST /fhir/$:operation
```

Use `GET` for operations that only read data, or `POST` for operations that require input parameters.

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST \
       -H "Content-Type: application/fhir+json" \
       -d '{"resourceType":"Parameters"}' \
       https://your-server.com/fhir/$validate
  ```

  ```bash HTTP theme={null}
  POST /fhir/$validate HTTP/1.1
  Host: your-server.com
  Content-Type: application/fhir+json

  {
    "resourceType": "Parameters",
    ...
  }
  ```
</CodeGroup>

## Common System Operations

### \$validate

Validate a resource against profiles and constraints:

```json theme={null}
POST /fhir/$validate
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        "name": [{"family": "Doe"}]
      }
    },
    {
      "name": "profile",
      "valueUri": "http://hl7.org/fhir/StructureDefinition/Patient"
    }
  ]
}
```

### \$export

Export all resources (if supported):

```json theme={null}
POST /fhir/$export
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "_outputFormat",
      "valueString": "application/fhir+ndjson"
    },
    {
      "name": "_type",
      "valueString": "Patient,Observation"
    }
  ]
}
```

### \$everything

Get all resources (if supported):

```bash theme={null}
GET /fhir/$everything
```

## Request Format

Operations use a `Parameters` resource for input:

```json theme={null}
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "parameter-name",
      "valueString": "parameter-value"
    },
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        ...
      }
    }
  ]
}
```

## Response

### Success (200 OK)

Returns operation results, typically as a `Parameters` resource or a `Bundle`:

```json theme={null}
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "result",
      "valueBoolean": true
    },
    {
      "name": "message",
      "valueString": "Validation passed"
    }
  ]
}
```

### Error (400 Bad Request)

Returns an `OperationOutcome` if the operation fails:

```json theme={null}
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "Operation $unknown not supported"
      }
    }
  ]
}
```

## Available Operations

The available system-level operations depend on server configuration. Check the capability statement (`/fhir/metadata`) to see which operations are supported:

```json theme={null}
{
  "rest": [
    {
      "operation": [
        {
          "name": "$validate",
          "definition": "http://hl7.org/fhir/OperationDefinition/Resource-validate"
        },
        {
          "name": "$export",
          "definition": "http://hl7.org/fhir/OperationDefinition/System-export"
        }
      ]
    }
  ]
}
```

## Notes

* System operations affect the entire server
* Available operations are listed in the capability statement
* Operations may require specific permissions
* Use POST when operations require input parameters
* Operation names are case-sensitive and start with `$`
