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

# Manage points transaction

> Create a points transaction (credit or debit) for a user's account



## OpenAPI

````yaml /openapi/admin.json post /users/{id}/points-transaction
openapi: 3.1.0
info:
  title: Nudj Admin API
  version: 1.0.0
servers:
  - url: https://{subdomain}.nudj.cx/api/v2/admin
    description: Organization API Server
    variables:
      subdomain:
        description: Your organization's subdomain (required)
        default: your-org
security:
  - ApiToken: []
paths:
  /users/{id}/points-transaction:
    post:
      tags:
        - User
      summary: Manage points transaction
      description: Create a points transaction (credit or debit) for a user's account
      operationId: managePointsTransaction
      parameters:
        - in: path
          name: id
          description: >-
            ID of the user for the points transaction, this can be the Nudj user
            ID or the external user ID
          schema:
            type: string
            description: >-
              ID of the user for the points transaction, this can be the Nudj
              user ID or the external user ID
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: number
                  minimum: 1
                  maximum: 1000000
                  description: Number of points for the transaction
                direction:
                  type: string
                  enum:
                    - credit
                    - debit
                  description: >-
                    Direction of the transaction: Credit to add points, Debit to
                    deduct points
                communityId:
                  type: string
                  description: >-
                    ID of the community for the transaction. Required if
                    organization has multiple communities
                externalTransactionReference:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: >-
                    Unique reference provided by the admin to track this
                    transaction
              required:
                - amount
                - direction
                - externalTransactionReference
              description: Input for managing points transactions (credit or debit)
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagePointsTransactionOutput'
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
components:
  schemas:
    ManagePointsTransactionOutput:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
        transaction:
          $ref: '#/components/schemas/PointsTransaction'
      required:
        - success
        - message
        - transaction
      description: Output of the points transaction operation
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Error
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
    PointsTransaction:
      type: object
      properties:
        id:
          type: string
        organisationId:
          type: string
        communityId:
          type:
            - string
            - 'null'
        userId:
          type: string
        accountingDirection:
          type: string
          enum:
            - credit
            - debit
        amount:
          type: number
        status:
          type: string
          enum:
            - pending
            - completed
            - failed
        createdAt:
          type: string
        externalTransactionReference:
          type:
            - string
            - 'null'
        createdBy:
          type: string
        updatedBy:
          type: string
      required:
        - id
        - organisationId
        - userId
        - accountingDirection
        - amount
        - status
        - createdAt
        - externalTransactionReference
        - createdBy
        - updatedBy
      description: A points transaction
      title: Points Transaction
  securitySchemes:
    ApiToken:
      type: apiKey
      in: header
      name: x-api-token

````