---
title: "Bind a route to a function"
method: PUT
path: "/functions/{id}/route"
tags: ["Functions"]
---

# Bind a route to a function

`PUT /functions/{id}/route`

Binds inbound mail to this function. The route target is either
a specific verified domain (scoped) or the org's fallback (any
active domain with no scoped binding). If another function is
already bound at the target, returns a `conflict` envelope
describing the holder; re-issue with `takeover: true` to
deactivate that prior binding and install this one.

## Request body

- object — Target for a route binding. Either a specific verified domain (scoped) or the org-wide fallback. Pass `takeover: true` to deactivate any conflicting binding before installing this one.
  - `target` union, required
    - object
      - `kind` 'domain', required
      - `domainId` string, uuid, required
    - object
      - `kind` 'fallback', required
  - `takeover` boolean — When true, deactivate any conflicting binding before installing this one.

## Response `200`

Route bound, or conflict requiring takeover

- object
  - `success` true, required
  - `data` object, required — On success, carries the new `routing`. On conflict, carries `conflict` describing the binding holder so the caller can re-issue with `takeover: true`.
    - `routing` object, nullable — A single route binding for a function. `domain` is null when the binding is the org's fallback (any active domain without a scoped binding); otherwise it carries the scoped domain. `rules` is reserved for future routing predicates.
      - `endpoint_id` string, uuid, required
      - `enabled` boolean, required
      - `domain` object, nullable, required
        - `id` string, uuid, required
        - `name` string, nullable
      - `rules` object, required — Future routing predicates. Currently empty.
      - `delivery_count` integer
      - `success_count` integer
      - `failure_count` integer
      - `consecutive_fails` integer
      - `last_delivery_at` string, date-time, nullable
      - `last_success_at` string, date-time, nullable
      - `last_failure_at` string, date-time, nullable
    - `conflict` object
      - `kind` 'http' | 'function', required
      - `functionId` string, uuid, nullable
      - `functionName` string, nullable
      - `url` string, nullable

## Other responses

- `400` — Invalid request parameters
- `401` — Invalid or missing API key
- `404` — Resource not found

---

[API](https://skmtc.dev/primitive/apis/primitive-api.md) · [All operations](https://skmtc.dev/primitive/apis/primitive-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/primitive/primitive-api/revisions/c2299d28022c/schema)
