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

# Create a new metric

> Creates a new metric.



## OpenAPI

````yaml /openapi/squad-api.json post /organisations/{orgId}/workspaces/{workspaceId}/metrics
openapi: 3.1.0
info:
  title: Squad API
  version: 4.8.0
  description: API for managing Squad resources
  contact:
    name: Squad Support
    url: https://www.meetsquad.ai/support
    email: help@meetsquad.ai
servers:
  - url: https://api.meetsquad.ai
    description: Production server
  - url: https://uat.api.meetsquad.ai
    description: Staging server
  - url: https://dev.api.meetsquad.ai
    description: Development server
security: []
tags:
  - name: Organisations
  - name: Workspaces
  - name: Goals
  - name: Opportunities
  - name: Solutions
  - name: Feedback
  - name: Submit Feedback
  - name: Insights
  - name: Knowledge
  - name: Metrics
  - name: Topics
  - name: Integrations
  - name: AI & Search
  - name: Onboarding
paths:
  /organisations/{orgId}/workspaces/{workspaceId}/metrics:
    post:
      tags:
        - Metrics
      summary: Create a new metric
      description: Creates a new metric.
      operationId: createMetric
      parameters:
        - in: path
          name: orgId
          schema:
            type: string
          required: true
          description: Organization ID
          example: a5f3c6e1-9d20-4f7b-8e31-d09a2b63c184
        - in: path
          name: workspaceId
          schema:
            type: string
          required: true
          description: Workspace ID
          example: c0e195d9-b918-4a3a-bd8b-f730361d044f
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMetricPayload'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                description: Response containing a single  metric
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Metric'
                required:
                  - data
                additionalProperties: false
        '400':
          description: Bad Request - Invalid input
          content:
            application/json:
              schema:
                description: >-
                  Bad Request - Invalid input parameters or missing required
                  fields
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        description: Error code identifier
                        example: INVALID_REQUEST
                        type: string
                      description:
                        description: Human-readable error description
                        example: One or more fields are invalid
                        type: string
                      fields:
                        description: List of field names that are missing or invalid
                        example:
                          - title
                          - description
                        type: array
                        items:
                          type: string
                      validationErrors:
                        description: >-
                          Detailed validation error information for each invalid
                          field
                        example:
                          invalidFields:
                            title:
                              type: too_small
                              message: Title must be at least 3 characters long
                              path:
                                - title
                            deadline:
                              type: invalid_date
                              message: Deadline must be a valid date in the future
                              path:
                                - deadline
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                    required:
                      - code
                      - description
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                description: Unauthorized - Missing or invalid authentication token
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        description: Error code identifier
                        example: UNAUTHORISED_ERROR
                        type: string
                      description:
                        description: Human-readable error description
                        example: User is unauthenticated
                        type: string
                    required:
                      - code
                      - description
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '403':
          description: Forbidden - Insufficient permissions
          content:
            application/json:
              schema:
                description: Forbidden - Insufficient permissions to access this resource
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        description: Error code identifier
                        example: UNAUTHORISED_ERROR
                        type: string
                      description:
                        description: Human-readable error description
                        example: User is unauthorised
                        type: string
                    required:
                      - code
                      - description
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                description: >-
                  Internal Server Error - An unexpected error occurred on the
                  server
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        description: Error code identifier
                        example: INTERNAL_SERVER_ERROR
                        type: string
                      description:
                        description: Human-readable error description
                        example: An unexpected error occurred on the server
                        type: string
                    required:
                      - code
                      - description
                    additionalProperties: false
                required:
                  - error
                additionalProperties: false
      security:
        - bearerAuth: []
components:
  schemas:
    CreateMetricPayload:
      description: Request schema for creating a metric
      type: object
      properties:
        title:
          description: Display name for the metric
          example: Daily Active Users
          type: string
        description:
          description: Detailed description of the metric
          example: Number of unique users who performed any action in the last 24 hours
          type: string
        unit:
          description: Unit of measurement for the metric
          example: users
          type: string
        type:
          description: Category/type of the metric
          default: custom
          type: string
          enum:
            - engagement
            - conversion
            - revenue
            - nps
            - csat
            - ces
            - ratio
            - custom
        targetOperator:
          description: Comparison operator for the target
          type: string
          enum:
            - greater_than
            - less_than
            - equal_to
        targetValue:
          description: Target value to achieve
          example: 100
          type: number
        targetDirection:
          description: >-
            Direction of improvement (up = higher is better, down = lower is
            better)
          default: up
          type: string
          enum:
            - up
            - down
        currentValue:
          description: Current value of the metric
          example: 150
          type: number
        previousValue:
          description: Previous value of the metric for comparison
          example: 140
          type: number
        periodType:
          description: Type of period for metric comparison
          example: calendar
          type: string
          enum:
            - rolling
            - calendar
        periodValue:
          description: Specific period value for metric comparison
          example: month
          type: string
          enum:
            - day
            - week
            - month
            - quarter
            - year
            - 7-day
            - 30-day
            - 90-day
        timeseries:
          description: Historical values for trend analysis
          type: array
          items:
            $ref: '#/components/schemas/MetricTimeseriesPoint'
        relatedOutcomes:
          description: Related outcomes that use this metric
          type: array
          items: {}
        id:
          anyOf:
            - type: string
              format: uuid
              pattern: >-
                ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            - type: string
              const: ''
        outcomeIds:
          description: Array of outcome IDs to associate with this metric
          example:
            - 7b9e5d2c-f314-48a9-be56-9843a2f6c019
          type: array
          items:
            type: string
        ownerId:
          type: string
      required:
        - title
        - ownerId
    Metric:
      description: Metric data representing a measurable KPI result
      type: object
      properties:
        id:
          description: Unique identifier for the metric
          example: 7b9e5d2c-f314-48a9-be56-9843a2f6c019
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
        title:
          description: Display name for the metric
          example: Daily Active Users
          type: string
        description:
          description: Detailed description of the metric
          example: Number of unique users who performed any action in the last 24 hours
          type: string
        unit:
          description: Unit of measurement for the metric
          example: users
          type: string
        type:
          description: Category/type of the metric
          default: custom
          type: string
          enum:
            - engagement
            - conversion
            - revenue
            - nps
            - csat
            - ces
            - ratio
            - custom
        targetOperator:
          description: Comparison operator for the target
          type: string
          enum:
            - greater_than
            - less_than
            - equal_to
        targetValue:
          description: Target value to achieve
          example: 100
          type: number
        targetDirection:
          description: >-
            Direction of improvement (up = higher is better, down = lower is
            better)
          default: up
          type: string
          enum:
            - up
            - down
        currentValue:
          description: Current value of the metric
          example: 150
          type: number
        previousValue:
          description: Previous value of the metric for comparison
          example: 140
          type: number
        periodType:
          description: Type of period for metric comparison
          example: calendar
          type: string
          enum:
            - rolling
            - calendar
        periodValue:
          description: Specific period value for metric comparison
          example: month
          type: string
          enum:
            - day
            - week
            - month
            - quarter
            - year
            - 7-day
            - 30-day
            - 90-day
        ownerId:
          description: UserId of the Owner/responsible person for this metric
          example: user_123456789
          type: string
        timeseries:
          description: Historical values for trend analysis
          type: array
          items:
            $ref: '#/components/schemas/MetricTimeseriesPointOutput'
        createdAt:
          description: Timestamp of when the metric was created
          example: '2023-01-01T00:00:00.000Z'
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        updatedAt:
          description: Timestamp of when the metric was last updated
          example: '2023-01-01T00:00:00.000Z'
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        relatedOutcomes:
          description: Related outcomes that use this metric
          type: array
          items: {}
      required:
        - id
        - title
        - ownerId
        - createdAt
        - updatedAt
      additionalProperties: false
    MetricTimeseriesPoint:
      description: A single data point in a metric's time series
      type: object
      properties:
        date:
          description: ISO datetime string for the data point
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        value:
          description: Metric value at this point in time
          example: 85
          type: number
      required:
        - date
        - value
    MetricTimeseriesPointOutput:
      description: A single data point in a metric's time series
      type: object
      properties:
        date:
          description: ISO datetime string for the data point
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
        value:
          description: Metric value at this point in time
          example: 85
          type: number
      required:
        - date
        - value
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT authentication for organization-scoped endpoints.

````