# Assigning events to services

Copy as Markdown[View as Markdown](/docs/development/guides/messages/common/map-to-producers-and-consumers.md)

***

[Services](/docs/development/guides/services/introduction.md) can either **send** or **receive** events, commands and queries.

To add messages to services you need to reference them within your service itself by adding the `id`. The `version` is optional and if not provided the latest version will be used.

/services/Orders/index.mdx (example)

```
---
id: OrderService
... # other service frontmatter
receives:
    # id of the message this service receives
    - id: OrderPlaced
    # (optional) The version of the message you want to add
      version: 0.0.1
sends:  
    # id of the message this service sends
    - id: PaymentProcessed
---

<!-- Markdown contents... -->
```

### Versioning[​](#versioning "Direct link to Versioning")

When you reference a message in your service you can specify the version of the message.

This allows you to document which versions of messages your service interacts with.

If you don't specify a version the latest version will be used.
