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

# Track a conversion

> Credits a lead or sale to a short-link click. CORS is open. Prefer the tracking snippet on the destination site; call this endpoint from a server when the snippet cannot run. If `orderId` was already credited, the response is `{ ok: true, duplicate: true }`.



## OpenAPI

````yaml /openapi.json post /api/v1/convert
openapi: 3.1.0
info:
  title: TrimYourl API
  version: 1.0.0
  description: >-
    Create branded short links, update them, download QR codes, read analytics,
    and credit conversions. Authenticate with a workspace API key from Settings
    → API.
servers:
  - url: https://trimyourl.com
    description: Production
security: []
tags:
  - name: Links
    description: >-
      Create, list, update, and delete short links in the workspace that owns
      the API key.
  - name: Analytics
    description: >-
      Human clicks, bots, devices, geo, and referrers for a workspace or a
      single link.
  - name: Domains
    description: Active short-link hostnames in the workspace.
  - name: QR codes
    description: Download a PNG for an existing link using the workspace QR kit.
  - name: Conversions
    description: >-
      Credit a purchase or sign-up to the short-link click that brought the
      visitor.
paths:
  /api/v1/convert:
    post:
      tags:
        - Conversions
      summary: Track a conversion
      description: >-
        Credits a lead or sale to a short-link click. CORS is open. Prefer the
        tracking snippet on the destination site; call this endpoint from a
        server when the snippet cannot run. If `orderId` was already credited,
        the response is `{ ok: true, duplicate: true }`.
      operationId: trackConversion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Conversion'
            example:
              kid: click-id-from-query-or-cookie
              client: trk_ab12cd34ef56
              event: purchase
              value: 49.99
              currency: USD
              orderId: '1001'
      responses:
        '200':
          description: Credited, duplicate, or outside the attribution window.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResult'
              examples:
                credited:
                  value:
                    ok: true
                    event: purchase
                    slug: spring-launch
                duplicate:
                  value:
                    ok: true
                    duplicate: true
                window:
                  value:
                    ok: false
                    reason: window
        '400':
          description: Missing `kid`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResult'
              example:
                ok: false
                reason: kid
        '403':
          description: '`client` did not match the workspace tracking key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResult'
              example:
                ok: false
                reason: client
        '404':
          description: Unknown click, or the click was a bot.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversionResult'
              examples:
                unknown:
                  value:
                    ok: false
                    reason: unknown
                bot:
                  value:
                    ok: false
                    reason: bot
      security: []
components:
  schemas:
    Conversion:
      type: object
      required:
        - kid
      properties:
        kid:
          type: string
          description: >-
            Click id from the `kid` query param on the destination, or the
            `tyl_kid` cookie.
        client:
          type: string
          description: >-
            Workspace tracking key (`trk_…`). Required to match if the workspace
            has one.
        event:
          type: string
          description: >-
            Event name such as `purchase` or `sign_up`. `purchase` and `sale`
            count as sales.
        kind:
          type: string
          description: >-
            Optional override. Use `sale` to force a sale when the event name is
            custom.
        value:
          type: number
          description: Amount in major currency units (for example `49.99`).
        amount:
          type: number
          description: Alias for `value`.
        currency:
          type: string
          description: ISO 4217 code. Defaults to the workspace currency.
        orderId:
          type: string
          description: Deduplicates reloads of a thank-you page.
    ConversionResult:
      type: object
      properties:
        ok:
          type: boolean
        event:
          type: string
        slug:
          type: string
          nullable: true
        duplicate:
          type: boolean
        reason:
          type: string
          enum:
            - kid
            - unknown
            - bot
            - client
            - window

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.