# Create an authorization payment

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/idempotency)

Authorizes a specific amount in customer's Credit card, which can be collected within a span of time. Read more on authorization and capture [here](https://www.chargebee.com/docs/payments/2.0/payment-gateways-and-configuration/stripe#auth-and-capture).

-   Supported only for Card payments.
-   Currently supported only for **Stripe**.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/transactions/create_authorization \
     -u {site_api_key}:\
     -d customer_id="__test__KyVnHhSBWltgF2p6" \
     -d amount=1000
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Transaction.CreateAuthorization()
		.CustomerId("__test__KyVnHhSBWltgF2p6")
		.Amount(1000)
		.Request();

Transaction transaction = result.Transaction;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    transactionAction "github.com/chargebee/chargebee-go/v3/actions/transaction"
    "github.com/chargebee/chargebee-go/v3/models/transaction"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := transactionAction.CreateAuthorization(&transaction.CreateAuthorizationRequestParams{
        CustomerId : "__test__KyVnHhSBWltgF2p6",
        Amount : chargebee.Int64(1000),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Transaction := res.Transaction
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.TransactionCreateAuthorizationRequest{
    CustomerId : "__test__KyVnHhSBWltgF2p6",
    Amount : chargebee.Int64(1000),
}
  res, err := client.Transaction.CreateAuthorization(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Transaction := res.Transaction
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Transaction.createAuthorization()
            .customerId("__test__KyVnHhSBWltgF2p6")
            .amount(1000L)
            .request();

        Transaction transaction = result.transaction();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.transaction.Transaction;
import com.chargebee.v4.models.transaction.params.TransactionCreateAuthorizationParams;
import com.chargebee.v4.models.transaction.responses.TransactionCreateAuthorizationResponse;

public class TransactionCreateAuthorization {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        TransactionCreateAuthorizationParams params = TransactionCreateAuthorizationParams.builder()
            .customerId("__test__KyVnHhSBWltgF2p6")
            .amount(1000L)
            .build();

        TransactionCreateAuthorizationResponse response = client.transactions().createAuthorization(params);

        Transaction transaction = response.getTransaction();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.transaction.createAuthorization({
        customer_id: "__test__KyVnHhSBWltgF2p6",
        amount: 1000
    });

    console.log(result);
    const transaction = result.transaction;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->transaction()->createAuthorization([
    "customer_id" => "__test__KyVnHhSBWltgF2p6",
    "amount" => 1000
]);
$transaction = $result->transaction;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Transaction.create_authorization(
    cb_client.Transaction.CreateAuthorizationParams(
        customer_id="__test__KyVnHhSBWltgF2p6",
        amount=1000
    )
)
transaction = response.transaction
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Transaction.create_authorization({
  :customer_id => "__test__KyVnHhSBWltgF2p6",
  :amount => 1000
})

transaction = result.transaction
```

## Sample Response

```json
{
  "transaction": {
    "amount": 1000,
    "amount_capturable": 1000,
    "authorization_reason": "blocking_funds",
    "currency_code": "USD",
    "customer_id": "__test__KyVnHhSBWltgF2p6",
    "date": 1600968316,
    "deleted": false,
    "exchange_rate": 1,
    "fraud_reason": "Payment complete.",
    "gateway": "stripe",
    "gateway_account_id": "gw___test__KyVnGlSBWltbL2AB",
    "id": "txn___test__KyVnHhSBWltv42pB",
    "id_at_gateway": "ch_1HUyC0Jv9j0DyntJiR6W37yv",
    "linked_payments": {},
    "masked_card_number": "************1111",
    "object": "transaction",
    "payment_method": "card",
    "payment_source_id": "pm___test__KyVnHhSBWltu42p7",
    "resource_version": 1517505917000,
    "status": "success",
    "type": "authorization",
    "updated_at": 1517505917
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/transactions/create_authorization

## Input Parameters

- `customer_id` (required, string, max chars=50)
  Identifier of the customer.

- `payment_source_id` (optional, string, max chars=40)
  Payment source to be used for authorizing the transaction.

- `currency_code` (required if Multicurrency is enabled, string, max chars=3)
  The currency code (ISO 4217 format) of the transaction amount.

- `amount` (required, in cents, min=1)
  The amount to be blocked.

## Returns

- `transaction` (Transaction object)
  Resource object representing transaction
