---
title: "Set the source organization for custom agents in an enterprise"
method: PUT
path: "/enterprises/{enterprise}/copilot/custom-agents/source"
tags: ["copilot"]
---

# Set the source organization for custom agents in an enterprise

`PUT /enterprises/{enterprise}/copilot/custom-agents/source`

Sets an organization as the source for custom agent definitions and Copilot CLI client settings in the enterprise.
The organization must have a `.github-private` repository containing agent definitions.

By default, this endpoint also creates an enterprise-level ruleset to protect
agent definition files (agents/*.md and .github/agents/*.md). You can opt out
of ruleset creation by setting `create_ruleset` to `false`.

Enterprise owners with write access to AI Controls can use this endpoint.

OAuth app tokens and personal access tokens (classic) need the `admin:enterprise` scope to use this endpoint.

## Path parameters

- `enterprise` string, required

## Request body

- object
  - `organization_id` integer, required — The ID of the organization to use as the custom agents source.
  - `create_ruleset` boolean — Whether to create a ruleset to protect agent definition files. Defaults to true.

## Response `200`

Success

- object
  - `organization` object
    - `id` integer — The ID of the organization.
    - `login` string — The login name of the organization.
    - `avatar_url` string — The avatar URL of the organization.
  - `repository` object
    - `id` integer — The ID of the .github-private repository.
    - `name` string — The name of the repository.
    - `full_name` string — The full name of the repository (owner/name).
  - `ruleset` object — The created or existing ruleset (if create_ruleset was true).
    - `id` integer — The ID of the ruleset.
    - `name` string — The name of the ruleset.
    - `enforcement` string — The enforcement level of the ruleset.

## Other responses

- `401` — Requires authentication
- `403` — Forbidden
- `404` — Resource not found
- `422` — Validation failed
- `500` — Internal Error

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-2.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-2/versions/8ae6d0c8716e/schema)
