# PayloadMappingDefinition

Type: PayloadMappingDefinition

A mapping definition consisting of the used mappingEngine and the options required by this engine.

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

- `mappingEngine` (required)
  Type: string
  
  The mapping engine used to process incoming and outgoing messages. Available mapping engines are
  `JavaScript`, `Normalized`, `ConnectionStatus`, `RawMessage`, `Ditto`, `ImplicitThingCreation`, and `UpdateTwinWithLiveResponse`.

- `options` (required)
  Type: object
  
  Configuration options specific to the used mapping engine:
  
  #### JavaScript
    * `incomingScript` (`string`, required): The mapping script for incoming messages
    * `outgoingScript` (`string`, required): The mapping script for outgoing messages
    * `loadBytebufferJS` (`boolean`, optional): Whether or not ByteBufferJS library should be included
      (default: `false`)
    * `loadLongJS` (`boolean`, optional): Whether or not LongJS library should be included (default: `false`)
  
  #### Normalized
    * `fields` (`string`, optional): Comma separated list of fields included in the normalized message
      (default: all fields included)
  
  #### ConnectionStatus
    * `thingId` (`string`, required): The ID of the thing
    * `featureId` (`string`, optional): The ID of the modified feature (default: `ConnectionStatus`)
  
  #### RawMessage
    * `outgoingContentType` (`string`, optional): The fallback content type for outgoing messages.
    * `incomingMessageHeaders` (`object`, optional): The fallback headers for incoming messages
      containing the necessary information to map them to message commands and responses.
      The relevant header keys are: `content-type`, `ditto-message-subject`, `ditto-message-direction`,
      `ditto-message-thing-id`, `ditto-message-feature-id` and `status`. The header values may contain
      placeholder expressions.
  
  #### Ditto
    * no options required
  
  #### ImplicitThingCreation
    * `thing` (`object`, required): The template of the thing to be implicitly created
  
  #### UpdateTwinWithLiveResponse
    * `dittoHeadersForMerge` (`object`, optional): The Ditto headers to use for constructing the "merge thing"
       command for updating the twin, may for example add a condition to apply in order to update the twin
       (default ditto headers: `response-required: false`, `if-match: "*"`).

- `incomingConditions` (optional)
  Type: object
  
  Optional conditions to be checked before applying the mapping engine to inbound messages.
  Can use placeholders and functional expressions.

- `outgoingConditions` (optional)
  Type: object
  
  Optional conditions to be checked before applying the mapping engine to outbound messages.
  Can use placeholders and functional expressions.