# Source

Type: Source

A subscription source subscribed by this connection

Schema: [Source](https://sourcey-ditto.pages.dev/http-api-doc/models/source.md)

- `addresses` (optional)
  Type: Array<string>
  
  The source addresses this connection consumes messages from. The "telemetry", "events",
  "command_response" aliases should be used for connections of type "hono".
  
  
  uniqueItems: true
  
  Items:
    Type: string
    
    A source address to consume messages from

- `consumerCount` (optional)
  Type: integer
  
  The number of consumers that should be attached to each source address
  
  default: 1

- `qos` (optional)
  Type: integer
  
  Maximum Quality-of-Service level to request when subscribing for messages

- `authorizationContext` (optional)
  Type: Array<string>
  
  The authorization context defines all authorization subjects associated for this source
  
  uniqueItems: true
  
  Items:
    Type: string
    
    An authorization subject associated with this source.
    You can either use a fixed subject or use a placeholder that resolves header values from incoming messages.
    For example to use the `device_id` header in the subject, you can specify the placeholder
    `{{ header:device_id }}` which is then replaced by Ditto when a message from this source is processed.
    By using a placeholder you can access any header value: `{{ header:<any-header-name> }}`
    
    Example:
    
    ```json
    [
      "ditto:myAuthorizationSubject",
      "device:{{ header:device_id }}"
    ]
    ```

- `enforcement` (optional)
  Type: object
  
  Defines an enforcement for this source to make sure that a device can only access its associated Thing.
  
  - `input` (required)
    Type: string
    
    The input value of the enforcement that should identify the origin of the message (e.g. a
    device id). You can use placeholders within this field depending on the connection type. E.g. for AMQP
    1.0 connections you can use `{{ header:[any-header-name] }}` to resolve the value from a message header.
    
    Example:
    
    ```json
    "{{ header:device_id }}"
    ```
  
  - `filters` (required)
    Type: Array<string>
    
    An array of filters. One of the defined filters must match the input value from the message otherwise the message is rejected.
    
    uniqueItems: true
    
    Items:
      Type: string
      
      A filter that must match the input value for a message to be accepted. You can use the placeholders
       `{{ thing:id }}`, `{{ thing:name }}` or `{{ thing:namespace }}` in a filter.
      
      Example:
      
      ```json
      [
        "{{ thing:id }}",
        "{{ thing:namespace }}/{{ thing:name }}"
      ]
      ```

- `acknowledgementRequests` (optional)
  Type: object
  
  Contains requests to acknowledgements which must be fulfilled before a message consumed from this source is technically settled/ACKed at the e.g. message broker.
  
  - `includes` (required)
    Type: Array<string>
    
    Acknowledgement requests to be included for each message consumed by this source.
    
    Items:
      Type: string
  
  - `filter` (optional)
    Type: string
    
    Optional filter to be applied to the requested acknowledgements - takes an `fn:filter()` function expression
    
    Example:
    
    ```json
    [
      "fn:filter(header:qos,'ne',0)"
    ]
    ```
  
  Additional properties: false

- `payloadMapping` (optional)
  Type: Array<string>
  
  A list of payload mappings that are applied to messages received via this source. If no payload mapping is specified the standard Ditto mapping is used as default.
  
  Items:
    Type: string
    
    References a payload mapping definition by its ID (the key of the PayloadMappingDefinition)
    
    Example:
    
    ```json
    [
      "Ditto",
      "status"
    ]
    ```

- `headerMapping` (optional)
  Type: object
  
  Ditto protocol headers computed from external headers and certain properties of the Ditto protocol messages created by payload mapping.

- `replyTarget` (optional)
  Type: object
  
  Configuration for sending responses of incoming commands.
  
  - `enabled` (optional)
    Type: boolean
    
    Whether reply target is enabled.
  
  - `address` (required)
    Type: string
    
    The target address where responses of incoming commands from the parent source are published to.
    The following placeholders are allowed within the target address:
    
    * Thing ID: `{{ thing:id }}`
    
    * Thing Namespace: `{{ thing:namespace }}`
    
    * Thing Name: `{{ thing:name }}` (the part of the ID without the namespace)
    
    * Ditto protocol topic attribute: `{{ topic:[topic-placeholder-attr] }}`
    
    * Ditto protocol header value: `{{ header:[any-header-name] }}`
    
    If placeholder resolution fails for a response, then the response is dropped.
    NOTE Use "command" alias for connections of type "hono".
    
    Example:
    
    ```json
    [
      "{{ header:device_id }}",
      "{{ source:address }}"
    ]
    ```
  
  - `headerMapping` (optional)
    Type: object
    
    External headers computed from headers and other properties of Ditto protocol messages.
  
  - `expectedResponseTypes` (optional)
    Type: Array<string>
    
    Contains a list of response types that should be published to the reply target.
    
    uniqueItems: true
    
    Items:
      Type: string
      
      enum: ["response","error","nack"]
  
  Additional properties: false