Authorize a Transaction

Estimated time: ~1 minute

Each transaction requires an approve or decline decision from the card issuer. This is called an "authorization". Using Lithic's Authorization Rules you can define when a transaction should be automatically approved or declined.

Create an Authorization Rule

For example, you can add an Authorization Rule to only allow transactions in the United States and Lithic will automatically decline any transaction that occurs in another country.

/*
const lithic = new Lithic({
  apiKey: "{Sandbox API key}", // or "Production API key"
  environment: "sandbox", // or "production". Defaults to "production"
});
*/

const rule_params: AuthRuleCreateParams = {
    allowed_countries: ["USA"],
    card_tokens: ["{Card Token}"] // apply rule to every transaction that occurs on this card
  };
const rule = await lithic.authRules.create(rule)
'''
lithic = Lithic(
  api_key="{Sandbox API key}",  # or "Production API key"
  environment="sandbox",  # or "production". Defaults to "production"
)
'''

rule = lithic.authRules.create({
  "allowed_countries": ["USA"],
  "card_tokens": ["{Card Token}"] # apply rule to every transaction that occurs on this card
})
curl --request POST \
     --url https://sandbox.lithic.com/v1/auth_rules \
     --header "Accept: application/json" \
     --header "Authorization: {Sandbox API key}" \
     --header "Content-Type: application/json" \
     --data '
{
     "allowed_countries": [
          "USA"
     ],
     "card_tokens": [
          "{Card Token}"
     ]
}
'

For more information on authorization rules, check out our in-depth guide: Authorization Rules