# Connect Gitea

> Connect your own Gitea server to AI CodeOps with a personal access token: the instance URL, the token scopes it needs, and how pull requests are opened for you.

Source: https://aicodeops.dev/docs/git/gitea

AI CodeOps works with Gitea servers you run. You connect with your server's address and a personal access token. Sessions then write changes on a new branch and open a pull request on your server for review.

## Before you start

- Your Gitea server's public **https** address, for example `https://gitea.example.com`. AI CodeOps runs in the cloud, so it must be able to reach the server over the internet.
- Addresses on private networks, `localhost`, link-local addresses and `.local` or `.internal` names are refused. So are URLs with a query string or `#fragment`. The error says: "Use the public https address of your Git server".
- An account with write access to the repositories you want to use.

## Create a token in Gitea

1. In Gitea, open **Settings → Applications** and generate a new token.
2. Give it read and write access to **repository** (to clone, push branches, and create and merge pull requests) and read access to **user** (to show which account is connected).
3. Copy the token. Gitea shows it only once.

## Connect the token

1. In your workspace, open **Configure → Settings** and scroll to **Git Providers**.
2. On the **Gitea** card, enter the **Instance URL**. It is required.
3. Paste the token into **or access token** and choose **Connect with token**.

AI CodeOps checks the token against your server before it saves it. "Token rejected — check the URL and key." means the address or the token is wrong, or the token lacks a scope.

## OAuth

The card also has **Connect via OAuth**. It only works for the one Gitea or Forgejo server the platform's OAuth app is registered on. For your own server you will see "sign-in isn't set up on this server": use a token.

## What AI CodeOps does with the repository

- **Browse:** **Develop → Repositories** lists the repositories the account can see, with branches, files and pull requests.
- **Branches and pull requests:** when a change is approved and passes its [quality gates](https://aicodeops.dev/docs/quality-gates), AI CodeOps pushes a branch named `codeops/run-<id>` and opens a pull request into the project's default branch. Commits are authored as "AI CodeOps".
- **Merge:** a pull request the console opened can be merged from the console. The release gate runs again first.

AI CodeOps doesn't install webhooks on your server or comment on pull requests.

## Your token and your access

- A connection belongs to you, not the workspace. Workspace roles still decide what each member can do.
- The token is encrypted at rest (AES-256-GCM) and isn't written into any repository's Git configuration.
- To remove access, choose **Disconnect**, or delete the token in Gitea. To rotate a token, disconnect and connect again with the new one.

## Next steps

- [Create a project](https://aicodeops.dev/docs/projects) from a Gitea repository.
- [Run your first session](https://aicodeops.dev/docs/sessions).
- [Troubleshooting](https://aicodeops.dev/docs/troubleshooting)
