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

# Create an activity

> Creates a record of a customer having performed a given action.

export const scope_0 = "activity:write"

<Callout icon="key" iconType="regular">
  This endpoint requires the **{scope_0}** scope.
</Callout>

Once created, activities will be asynchronously evaluated against the loyalty program's configuration to determine if any rewards should be issued. This evaluation happens automatically and no additional API calls are required.


## OpenAPI

````yaml schemas/rest-api.json POST /activities
openapi: 3.1.0
info:
  title: Smile.io REST API
  version: 1.0.0
  description: A RESTful interface for interacting with Smile.io loyalty programs.
servers:
  - url: https://api.smile.io/v1
security:
  - bearerAuth: []
paths:
  /activities:
    post:
      tags:
        - Activities
      summary: Create an activity
      description: Creates a record of a customer having performed a given action.
      operationId: post__activities
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                activity:
                  type: object
                  properties:
                    token:
                      type: string
                      example: activity_f57a9b5a8d0ac5
                      description: A token identifying the activity that was performed.
                    distinct_id:
                      type: string
                      description: >-
                        A unique identifier for the activity in the external
                        system (e.g. the order number).
                      example: '212993'
                    created_on_origin_at:
                      type: string
                      description: >-
                        The date and time the activity was performed by the
                        customer in the external system (e.g. when the action
                        actually occurred, which is often earlier than when the
                        activity is created in Smile).
                      format: date-time
                      example: '2024-04-04T15:10:42.030Z'
                  required:
                    - token
                  oneOf:
                    - title: With customer ID
                      properties:
                        customer_id:
                          type: integer
                          example: 304169228
                          description: >-
                            The ID of the customer who performed the activity.
                            Required if `customer_email` is not provided.
                      required:
                        - customer_id
                    - title: With customer email
                      properties:
                        customer_email:
                          type: string
                          example: jane@doe.com
                          description: >-
                            The email of the customer who performed the
                            activity. Required if `customer_id` is not provided.
                          format: email
                      required:
                        - customer_email
              required:
                - activity
      responses:
        '201':
          description: The activity was successfully created.
          content:
            application/json:
              schema:
                type: object
                properties:
                  activity:
                    $ref: '#/components/schemas/Activity'
components:
  schemas:
    Activity:
      type: object
      properties:
        id:
          type: integer
          example: 503256787
          description: Unique identifier for the activity.
        customer_id:
          type: integer
          example: 304169228
          description: The ID of the customer who performed the activity.
        token:
          type: string
          example: activity_f57a9b5a8d0ac5
          description: A token identifying the activity that was performed.
        distinct_id:
          type:
            - string
            - 'null'
          example: '212993'
          description: >-
            A unique identifier for the activity in the external system (e.g.
            the order number).
        created_on_origin_at:
          type:
            - string
            - 'null'
          format: date-time
          example: '2024-04-04T15:10:42.030Z'
          description: >-
            The date and time the activity was performed by the customer in the
            external system (e.g. when the action actually occurred, which is
            often earlier than when the activity is created in Smile).
        created_at:
          type: string
          format: date-time
          example: '2024-05-15T08:35:08.920Z'
          description: The date and time when the activity was created.
        updated_at:
          type: string
          format: date-time
          example: '2024-05-15T08:35:08.920Z'
          description: The date and time when the activity was last updated.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````