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

# Revoke user consent

> Revoke consent for a user. Stored credentials are deleted and the affected devices stop receiving pulls and pushes. Pass a `deviceIds` array to scope the revocation; omit it to revoke every device under the user.



## OpenAPI

````yaml /openapi.json delete /users/{userId}/consent
openapi: 3.1.0
info:
  title: Amps.ai API
  description: >-
    Energy device management API for batteries, EV chargers, solar inverters,
    and HVAC systems
  version: '1.0'
  contact: {}
servers:
  - url: https://api.amps.ai
    description: Amps API
security: []
tags: []
paths:
  /users/{userId}/consent:
    delete:
      tags:
        - Users
      summary: Revoke user consent
      description: >-
        Revoke consent for a user. Stored credentials are deleted and the
        affected devices stop receiving pulls and pushes. Pass a `deviceIds`
        array to scope the revocation; omit it to revoke every device under the
        user.
      operationId: revokeConsent
      parameters:
        - name: userId
          required: true
          in: path
          description: The unique identifier for the user.
          schema:
            example: user_abc123
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RevokeConsentRequestDto'
            examples:
              revokeAllDevices:
                summary: Revoke consent for every device under this user
                description: >-
                  Send an empty body to revoke consent across every device the
                  user has connected. Credentials are deleted and devices stop
                  receiving pulls and pushes.
                value: {}
              revokeSpecificDevices:
                summary: Revoke consent for a subset of devices
                description: >-
                  Pass a `deviceIds` array to revoke consent only for the listed
                  devices. Other connected devices keep their credentials.
                value:
                  deviceIds:
                    - device_abc123
                    - device_xyz789
      responses:
        '200':
          description: Consent revoked successfully.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - meta
                properties:
                  success:
                    type: boolean
                    const: true
                    description: Always `true` for success responses.
                  data:
                    $ref: '#/components/schemas/RevokeConsentResponseDto'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
              examples:
                all_revoked:
                  summary: All devices revoked
                  value:
                    success: true
                    data:
                      success: true
                      userId: user_abc123
                      revokedDeviceCount: 2
                      revokedDeviceIds:
                        - device_abc123
                        - device_xyz789
                    meta:
                      requestId: req_8a2Bf3kP
                      environment: sandbox
                      timestamp: '2026-06-02T12:00:00.000Z'
                      latencyMs: 12
                none_to_revoke:
                  summary: User had no active consents
                  value:
                    success: true
                    data:
                      success: true
                      userId: user_abc123
                      revokedDeviceCount: 0
                      revokedDeviceIds: []
                    meta:
                      requestId: req_8a2Bf3kP
                      environment: sandbox
                      timestamp: '2026-06-02T12:00:00.000Z'
                      latencyMs: 12
        '400':
          description: Invalid request body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_device_ids:
                  summary: '`deviceIds` is not an array'
                  value:
                    success: false
                    error:
                      code: VALIDATION_ERROR
                      message: Request validation failed.
                      details:
                        deviceIds:
                          - Expected array, received string
                        description: Invalid request body
                    meta:
                      requestId: req_3kL9mNrZ
                      timestamp: '2026-04-29T12:00:00.000Z'
                      path: /users/user_abc123/consent
                      latencyMs: 4
        '401':
          description: Invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_api_key:
                  summary: No `x-api-key` header present
                  value:
                    success: false
                    error:
                      code: UNAUTHORIZED
                      message: Authentication is required.
                      details:
                        description: API key is required
                    meta:
                      requestId: req_8sW2dRtX
                      timestamp: '2026-04-29T12:00:00.000Z'
                      path: /users/user_abc123/consent
                      latencyMs: 2
        '404':
          description: User not found or access denied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                user_not_found:
                  summary: No user matches the ID for this customer
                  value:
                    success: false
                    error:
                      code: NOT_FOUND
                      message: The requested resource was not found.
                      details:
                        description: User not found or access denied
                    meta:
                      requestId: req_5pH1cQbY
                      timestamp: '2026-04-29T12:00:00.000Z'
                      path: /users/user_unknown_999/consent
                      latencyMs: 5
      security:
        - api-key: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl --request DELETE \
              --url 'https://api.amps.ai/users/user_abc123/consent' \
              --header 'x-api-key: amps_sk_test_xxxxxxxxxxxxxxxxxxxxxxxx' \
              --header 'content-type: application/json' \
              --data '{}'
        - lang: javascript
          label: Node
          source: >-
            const response = await
            fetch('https://api.amps.ai/users/user_abc123/consent', {
              method: 'DELETE',
              headers: {
                'x-api-key': 'amps_sk_test_xxxxxxxxxxxxxxxxxxxxxxxx',
                'content-type': 'application/json',
              },
              body: JSON.stringify({}),
            });


            const data = await response.json();
        - lang: python
          label: Python
          source: |-
            import requests

            url = 'https://api.amps.ai/users/user_abc123/consent'
            headers = {
                'x-api-key': 'amps_sk_test_xxxxxxxxxxxxxxxxxxxxxxxx',
                'content-type': 'application/json',
            }
            payload = {}

            response = requests.delete(url, headers=headers, json=payload)
            data = response.json()
components:
  schemas:
    RevokeConsentRequestDto:
      type: object
      properties:
        deviceIds:
          type: array
          items:
            type: string
      title: Revoke Consent
    RevokeConsentResponseDto:
      type: object
      properties:
        success:
          type: boolean
        userId:
          type: string
        revokedDeviceCount:
          type: number
        revokedDeviceIds:
          type: array
          items:
            type: string
      required:
        - success
        - userId
        - revokedDeviceCount
        - revokedDeviceIds
      title: Revoke Consent
    ResponseMeta:
      type: object
      title: Response Meta
      description: >-
        Metadata attached to every response: the request identifier, the serving
        environment, the build timestamp, and the server-side latency.
      required:
        - environment
        - timestamp
        - latencyMs
      properties:
        requestId:
          description: >-
            Unique request identifier. Echoes the `x-request-id` header when
            present; otherwise generated server-side.
          type: string
        environment:
          type: string
          description: The environment that served the request (`sandbox` or `live`).
        timestamp:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the response was built.
        latencyMs:
          type: integer
          description: Server-side processing time in milliseconds.
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Always `false` for error responses.
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - INVALID_CREDENTIALS
                - INVALID_API_KEY
                - INVALID_MFA_CODE
                - MFA_REQUIRED
                - ACCOUNT_LOCKED
                - UNSUPPORTED_CREDENTIAL_TYPE
                - DEVICE_NOT_FOUND
                - DEVICE_OFFLINE
                - DEVICE_UNAUTHORIZED
                - NO_DEVICES_FOUND
                - COMMAND_FAILED
                - COMMAND_NOT_SUPPORTED
                - EXECUTION_NOT_SUPPORTED
                - MODE_OVERRIDDEN
                - VPP_LOCKED
                - INVALID_PARAMETERS
                - INVALID_OEM_PARAMETERS
                - INVALID_TIME_WINDOW
                - BIND_NOT_SUPPORTED
                - SCHEDULER_ACTIVE
                - SCHEDULER_FULL
                - UNSUPPORTED_AUTH_PATH
                - SETTING_OUT_OF_RANGE
                - NETWORK_ERROR
                - RATE_LIMITED
                - SERVICE_UNAVAILABLE
                - TIMEOUT
                - NOT_YET_AVAILABLE
                - SIMULATED_FAILURE
                - UNKNOWN_ERROR
                - VEHICLE_NOT_CONNECTED
                - SESSIONS_NOT_SUPPORTED
                - CREDENTIAL_NOT_FOUND
                - OEM_CIRCUIT_OPEN
                - INVALID_OEM_RESPONSE
                - COMMAND_NOT_APPLIED
                - STALE_ACTION
                - DEFERRED_SCHEDULE_FAILED
                - UNROUTABLE_ACTION_TYPE
                - UNAUTHORIZED
                - EXPIRED_TOKEN
                - FORBIDDEN
                - INSUFFICIENT_PERMISSIONS
                - LIVE_ACCESS_DISABLED
                - VALIDATION_ERROR
                - INVALID_INPUT
                - INVALID_REQUEST_BODY
                - EMPTY_SETTINGS
                - PAYLOAD_TOO_LARGE
                - UNSUPPORTED_MEDIA_TYPE
                - NOT_FOUND
                - METHOD_NOT_ALLOWED
                - CONFLICT
                - CONFLICT_IN_EXECUTION
                - GONE
                - RATE_LIMIT_EXCEEDED
                - INTERNAL_ERROR
                - NOT_IMPLEMENTED
                - BAD_GATEWAY
                - GATEWAY_TIMEOUT
                - DEVICE_TYPE_MISMATCH
                - CONSENT_REVOKED
                - DEVICE_OVERAGE
                - SETTINGS_STORE_UNAVAILABLE
                - ACTION_NOT_FOUND
                - DIRECT_ACTION_UNSUPPORTED
                - UNSUPPORTED_ACTION
                - UNSUPPORTED_MODE
                - UNSUPPORTED_PARAMETER
                - UNSUPPORTED_PARAMETER_COMBINATION
                - UNSUPPORTED_UNIT
                - PARAMETER_OUT_OF_RANGE
                - START_IN_PAST
                - START_OUT_OF_RANGE
                - START_OFFSET_NOT_ACCEPTED
                - START_INVALID_FORMAT
                - START_NONEXISTENT_WALL_CLOCK
                - TIMEZONE_UNRESOLVED
                - INVALID_TIMEZONE
                - ACTION_NOT_CANCELLABLE
                - STRATEGY_NOT_SUPPORTED
                - UNSUPPORTED_SETTING
                - UNSUPPORTED_SETTING_COMBINATION
                - READ_ONLY_SETTING
                - INVALID_SETTING_UNIT
                - INVALID_SETTING_VALUE
                - NO_OP
                - NO_OVERRIDE
                - AVAILABILITY_ENV_UNSUPPORTED
                - UNSUPPORTED_COMBINATION
              description: >-
                Machine-readable error code (e.g. `VALIDATION_ERROR`,
                `CONFLICT`, `UNSUPPORTED_MODE`). Stable across releases; safe to
                switch on.
            message:
              type: string
              description: Human-readable error message.
            details:
              description: >-
                Structured context for the error: which fields were invalid,
                which actions conflicted, which capabilities the device
                declares. Shape varies by error code.
              type: object
              properties: {}
              additionalProperties: {}
          required:
            - code
            - message
          description: Error envelope.
        meta:
          type: object
          properties:
            requestId:
              description: >-
                Unique request identifier. Echoes the `x-request-id` header when
                present; otherwise generated server-side.
              type: string
            timestamp:
              type: string
              description: ISO 8601 timestamp when the error response was built.
            path:
              type: string
              description: Request path that produced the error.
            latencyMs:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
              description: Server-side processing time in milliseconds.
          required:
            - timestamp
            - path
            - latencyMs
          description: Request metadata.
      required:
        - success
        - error
        - meta
      title: Error Response
      description: >-
        Uniform error response. The `error.code` identifies the failure,
        `error.message` carries a human-readable explanation, and
        `error.details` carries structured context (failed fields, conflicting
        action IDs, supported capabilities) where relevant.
  securitySchemes:
    api-key:
      type: apiKey
      in: header
      name: x-api-key

````