# Auth Rules

## Overview
This document outlines the structure and parameters for retrieving Auth Rules from the Lithic API.

## Parameters

### ending_before
- **Type**: uuid  
  A cursor representing an item's token before which a page of results should end. Used to retrieve the previous page of results before this item.

### page_size
- **Type**: integer  
  1 to 100. Defaults to 50.  
  Page size (for pagination).

### starting_after
- **Type**: uuid  
  A cursor representing an item's token after which a page of results should begin. Used to retrieve the next page of results after this item.

### card_token
- **Type**: uuid  
  Only return Auth Rules that are bound to the provided card token.

### account_token
- **Type**: uuid  
  Only return Auth Rules that are bound to the provided account token.

### business_account_token
- **Type**: uuid  
  Only return Auth Rules that are bound to the provided business account token.

### scope
- **Type**: string (enum)  
  Only return Auth Rules that are bound to the provided scope.  
  Allowed: `PROGRAM`, `ACCOUNT`, `BUSINESS_ACCOUNT`, `CARD`, `ANY`

### event_stream
- **Type**: string (enum, deprecated)  
  Deprecated: Use `event_streams` instead. Only return Auth rules that are executed during the provided event stream.  
  Allowed: `AUTHORIZATION`, `THREE_DS_AUTHENTICATION`, `TOKENIZATION`, `ACH_CREDIT_RECEIPT`, `ACH_DEBIT_RECEIPT`, `CARD_TRANSACTION_UPDATE`, `ACH_PAYMENT_UPDATE`

### event_streams
- **Type**: array of strings  
  Only return Auth rules that are executed during any of the provided event streams. If `event_streams` and `event_stream` are specified, the values will be combined.

## Auth Rules Structure

### Response Structure
- **data**: Array of objects  
  - **token**: uuid (required) - Auth Rule Token  
  - **state**: string (enum, required) - The state of the Auth Rule (Allowed: `ACTIVE`, `INACTIVE`)
  - **program_level**: boolean (required) - Whether the Auth Rule applies to all authorizations on the card program.  
  - **card_tokens**: array of uuids (required) - Card tokens to which the Auth Rule applies.  
  - **excluded_card_tokens**: array of uuids - Card tokens to which the Auth Rule does not apply.  
  - **excluded_account_tokens**: array of uuids - Account tokens to which the Auth Rule does not apply.  
  - **excluded_business_account_tokens**: array of uuids - Business account tokens to which the Auth Rule does not apply.  
  - **account_tokens**: array of uuids (required) - Account tokens to which the Auth Rule applies.  
  - **business_account_tokens**: array of uuids (required) - Business Account tokens to which the Auth Rule applies.  
  - **type**: string (enum, required) - The type of Auth Rule.  
    - Allowed types: `CONDITIONAL_BLOCK`, `VELOCITY_LIMIT`, `MERCHANT_LOCK`, `CONDITIONAL_ACTION`, `TYPESCRIPT_CODE`
  - **current_version**: object (required) - Contains parameters and versioning for the Auth Rule.  
  - **draft_version**: object (required) - Contains draft parameters and versioning for the Auth Rule.  
  - **name**: string (required) - Auth Rule Name  
  - **event_stream**: string (enum, required) - The event stream during which the rule will be evaluated.  
  - **lithic_managed**: boolean (required) - Indicates whether this auth rule is managed by Lithic.

### Example Auth Rule
```json
{
  "data": [
    {
      "token": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "state": "ACTIVE",
      "program_level": true,
      "card_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "excluded_card_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "excluded_account_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "excluded_business_account_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "account_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "business_account_tokens": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
      "type": "CONDITIONAL_BLOCK",
      "current_version": {"parameters": {"conditions": [{"attribute": "MCC", "operation": "IS_ONE_OF", "value": "string"}]}, "version": 0},
      "draft_version": {"parameters": {"conditions": [{"attribute": "MCC", "operation": "IS_ONE_OF", "value": "string"}]}, "version": 0, "state": "PENDING", "error": "string"},
      "name": "string",
      "event_stream": "AUTHORIZATION",
      "lithic_managed": true
    }
  ],
  "has_more": true
}
```
