# Use Selection Rules and Templates

So far each request has named its host. With a Selection Rule, Cronofy
chooses the host from a group based on who's available. With a Template, the
meeting's details and hosts are set up in advance, so your application only
says who the meeting is with.

These use the same access token as
[Create a request with the API](https://docs.cronofy.com/developers/getting-started/first-api-request/index.md).

## Selection Rules
A Selection Rule is a group of members, and the number of them who need to
attend. Click **View Selection Rules** on the Hill Valley Futures page to see
the Sandbox's two:

- **Either Doc or Marty**: one of them attends.

- **Both Doc and Marty**: both of them attend.

Click a rule to see its `sub`, its members, and how many are required.

Use the rule's `sub` as the `host_group`:

```http
POST /v1/scheduling_requests HTTP/1.1
Host: {data_center_url}
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json; charset=utf-8

{
  "host_group": {
    "sub": "{SELECTION_RULE_SUB}"
  },
  "recipients": [
    {
      "email": "{YOUR_EMAIL}",
      "slot_selector": true
    }
  ],
  "event": {
    "summary": "Test meeting with Doc and Marty"
  }
}
```

Try each rule and compare the times offered:

- **Both Doc and Marty** only offers times when both are working: Monday to
Wednesday, 09:00 to 15:00.

- **Either Doc or Marty** offers any time one of them is working: Monday to
Wednesday, 08:00 to 17:00, and Thursday to Friday, 08:00 to 15:00.

Fewer required members, or more members to choose from, means more times to
offer.

## Templates
A Template describes a type of meeting: its title, length, location, and who
hosts it, which can be a Selection Rule. Click **View Templates** on the Hill
Valley Futures page to see the Sandbox's **Discuss Flux Capacitor project**
Template, a 30-minute meeting hosted by **Either Doc or Marty**.

Click the Template to see its `sub`. Then pass it with the recipient:

```http
POST /v1/scheduling_requests HTTP/1.1
Host: {data_center_url}
Authorization: Bearer {ACCESS_TOKEN}
Content-Type: application/json; charset=utf-8

{
  "template": {
    "sub": "{TEMPLATE_SUB}"
  },
  "recipients": [
    {
      "email": "{YOUR_EMAIL}",
      "slot_selector": true
    }
  ]
}
```

The Template provides the event details and the hosts.

Templates can't be created or edited in the Sandbox yet. A Selection Rule
that a Template uses, such as **Either Doc or Marty**, can't be deleted.

## Book them in your own page
Requests created from a Selection Rule or a Template have the same
`integration_operations` as any other, so you can offer their times in
[your own booking page](https://docs.cronofy.com/developers/getting-started/headless-selection/index.md).
Cronofy chooses the host when the time is booked.

## In your product
### In an applicant tracking system
Let each customer choose the Template an interview stage uses. When a candidate reaches that stage, create the request from the Template, and its Selection Rule picks interviewers from the panel, with booking limits spreading the load across them.

### In talent management
Set up Templates for each meeting type, such as a quarterly review, with a Selection Rule for the people who run them, such as the HR team.

### In a CRM
Use a Selection Rule to share meetings between the reps in a territory, and Templates for each meeting type, such as a discovery call or a demo.

### In healthtech
Use a Template for each appointment type, with its length and location, and a Selection Rule to pick a practitioner from the right specialty, with booking limits capping how many appointments each sees a day.

## Comparing the ways to choose a host
<table>
	<thead>
			<tr>
					<th>Method</th>
					<th>Who hosts</th>
					<th>What you pass</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Single host</td>
					<td>The member in `host`</td>
					<td>`host`, `recipients`, `event`</td>
			</tr>
			<tr>
					<td>Selection Rule</td>
					<td>Members of the rule, chosen by availability</td>
					<td>`host_group`, `recipients`, `event`</td>
			</tr>
			<tr>
					<td>Template</td>
					<td>Defined by the Template</td>
					<td>`template`, `recipients`</td>
			</tr>
	</tbody>
</table>
See [Create a Scheduling Request](https://docs.cronofy.com/api-reference/managed-scheduling/scheduling-requests/create/index.md)
and [Create using a Template](https://docs.cronofy.com/api-reference/managed-scheduling/scheduling-requests/create-requests-with-templates/index.md)
for every option, and
[Selection Rules](https://docs.cronofy.com/schedule/scheduling-and-booking/selection-rules/index.md)
and [Templates](https://docs.cronofy.com/schedule/scheduling-and-booking/templates/index.md)
for how your customers manage them.

## Next
You've worked through the Sandbox. To go to production, provision a
[Managed Organizational Unit](https://docs.cronofy.com/developers/managed-scheduling/managed-organizational-units/index.md) for each of your customers.



---
[Read in HTML](https://docs.cronofy.com/developers/getting-started/rules-and-templates/)