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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.kosli.com/feedback

```json
{
  "path": "/api-reference/trails/begin-trail",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Begin trail

> Add a Trail to a Flow.



## OpenAPI

````yaml https://app.kosli.com/api/v2/openapi.json put /trails/{org}/{flow_name}
openapi: 3.1.0
info:
  title: Kosli API
  summary: The API for communicating with Kosli
  description: >

    # Authentication 


    When making requests against Kosli API, you can authenticate your requests
    using a bearer token. 

    Set the bearer token in the request Authorization header to a valid API
    key. 

    API Keys can be personal or for service accounts. Check the [service
    accounts
    documentation](https://docs.kosli.com/getting_started/service-accounts/) for
    details. 


    ## Curl example


    ```shell

    curl -H "Authorization: Bearer <<your-api-key>>"
    https://app.kosli.com/api/v2/environments/<<your-org-name>>

    ```
  version: '2.0'
servers:
  - url: https://app.kosli.com/api/v2
    description: EU
  - url: https://app.us.kosli.com/api/v2
    description: US
security:
  - HTTPBearer: []
paths:
  /trails/{org}/{flow_name}:
    put:
      tags:
        - Trails
      summary: Begin trail
      description: Add a Trail to a Flow.
      operationId: create_trail_trails__org___flow_name__put
      parameters:
        - name: flow_name
          in: path
          required: true
          schema:
            type: string
            title: Flow Name
        - name: org
          in: path
          required: true
          schema:
            type: string
            title: Org
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_create_trail_trails__org___flow_name__put
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema: {}
      security:
        - HTTPBearer: []
        - HTTPBasic: []
components:
  schemas:
    Body_create_trail_trails__org___flow_name__put:
      properties:
        data_json:
          $ref: '#/components/schemas/CreateTrail'
          description: Trail metadata in JSON format
        template_file:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: Template File
          description: 'Optional flow template file (max size: 10MB)'
      type: object
      required:
        - data_json
      title: Body_create_trail_trails__org___flow_name__put
    CreateTrail:
      properties:
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        git_commit_info:
          anyOf:
            - $ref: '#/components/schemas/GitCommit'
            - type: 'null'
        repo_info:
          anyOf:
            - $ref: '#/components/schemas/RepoInfoPostInput'
            - type: 'null'
        origin_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Origin Url
        external_urls:
          anyOf:
            - patternProperties:
                ^[^=.]+$:
                  $ref: '#/components/schemas/ExternalAttachmentUrl'
              type: object
            - type: 'null'
          title: External Urls
        user_data:
          anyOf:
            - additionalProperties: true
              type: object
            - items: {}
              type: array
            - type: 'null'
          title: User Data
      type: object
      required:
        - name
      title: CreateTrail
    GitCommit:
      properties:
        sha1:
          type: string
          title: Sha1
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
        author:
          anyOf:
            - type: string
            - type: 'null'
          title: Author
        author_username:
          anyOf:
            - type: string
            - type: 'null'
          title: Author Username
        branch:
          anyOf:
            - type: string
            - type: 'null'
          title: Branch
        timestamp:
          anyOf:
            - type: number
            - type: 'null'
          title: Timestamp
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
        parents:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Parents
      type: object
      required:
        - sha1
      title: GitCommit
    RepoInfoPostInput:
      properties:
        name:
          type: string
          title: Name
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
        url:
          type: string
          title: Url
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        provider:
          anyOf:
            - type: string
              enum:
                - github
                - gitlab
                - bitbucket
                - azure-devops
                - circleci
            - type: 'null'
          title: Provider
      type: object
      required:
        - name
        - url
      title: RepoInfoPostInput
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````