> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trygroundai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sources

> Understanding and configuring sources in Ground

# Sources

Sources are the foundation of Ground. They represent the repositories and documentation you want to index and search.

## Source Types

### Repository Sources (`repo`)

Index code from Git repositories with language-aware chunking.

```json theme={null}
{
  "name": "My SDK",
  "source_type": "repo",
  "url": "https://github.com/org/repo",
  "branch": "main",
  "include_patterns": ["*.py", "*.ts"],
  "exclude_patterns": ["tests/**", "node_modules/**"]
}
```

**Fields:**

* `branch`: Git branch to index (default: `main`)
* `include_patterns`: Glob patterns for files to include
* `exclude_patterns`: Glob patterns for files to exclude

### Documentation Sources (`docs`)

Index documentation from websites or API specifications.

#### HTML Documentation

```json theme={null}
{
  "name": "FastAPI Docs",
  "source_type": "docs",
  "docs_format": "html",
  "url": "https://fastapi.tiangolo.com",
  "use_sitemap": true
}
```

Or with explicit URL list:

```json theme={null}
{
  "name": "Custom Docs",
  "source_type": "docs", 
  "docs_format": "html",
  "url": "https://docs.example.com",
  "doc_urls": [
    "https://docs.example.com/intro",
    "https://docs.example.com/guide"
  ]
}
```

#### OpenAPI Specifications

```json theme={null}
{
  "name": "Stripe API",
  "source_type": "docs",
  "docs_format": "openapi",
  "url": "https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json"
}
```

## Source Status

| Status    | Description                     |
| --------- | ------------------------------- |
| `pending` | Source created but never synced |
| `syncing` | Sync job currently running      |
| `synced`  | Successfully synced             |
| `error`   | Last sync failed                |

## API Operations

### Create Source

```bash theme={null}
curl -X POST https://api.trygroundai.com/sources \
  -H "Authorization: Bearer gnd_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Source",
    "source_type": "repo",
    "url": "https://github.com/org/repo"
  }'
```

### List Sources

```bash theme={null}
curl https://api.trygroundai.com/sources \
  -H "Authorization: Bearer gnd_your_api_key"
```

### Get Source

```bash theme={null}
curl https://api.trygroundai.com/sources/{source_id} \
  -H "Authorization: Bearer gnd_your_api_key"
```

### Update Source

```bash theme={null}
curl -X PATCH https://api.trygroundai.com/sources/{source_id} \
  -H "Authorization: Bearer gnd_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated Name"}'
```

### Delete Source

```bash theme={null}
curl -X DELETE https://api.trygroundai.com/sources/{source_id} \
  -H "Authorization: Bearer gnd_your_api_key"
```

### Trigger Sync

```bash theme={null}
curl -X POST https://api.trygroundai.com/sources/{source_id}/sync \
  -H "Authorization: Bearer gnd_your_api_key"
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use specific include/exclude patterns">
    Filter out generated files, tests, and dependencies to keep the index focused and efficient.
  </Accordion>

  <Accordion title="Set up regular syncs">
    Keep your sources fresh by syncing regularly. Stale sources show warnings in search results.
  </Accordion>

  <Accordion title="Use OpenAPI for API documentation">
    OpenAPI specs provide structured, version-tracked API information that's easier to search accurately.
  </Accordion>
</AccordionGroup>
