> This page is for MVS Pay.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mvscloud.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mvscloud.com/_mcp/server.

# Capture an authorization

POST https://pay.mvscloud.com/api/authorizations/{id}/capture
Content-Type: application/json

Captures a manual-capture authorization, optionally for a partial `amount_to_capture` (cents). Pass an `Idempotency-Key` header to make the capture safe to retry.

Reference: https://docs.mvscloud.com/mvs-pay/api/payments/capture-payment

## Authentication

- `x-api-key` header (required) — A scoped MvsPayApiKey, e.g. `mvspay_live_…`. Mint and scope keys from the dashboard (Settings → API Keys).

## Request

### Path parameters

- `id` (string, required) — The authorization (payment) id.

### Headers

- `Idempotency-Key` (string, optional) — Client-supplied idempotency key; a deterministic one is derived if omitted.

### Body (application/json)

This endpoint expects a PaymentCaptureRequest.

- `amount_to_capture` (integer, optional) — Positive integer (cents). Omit to capture the full authorized amount.

## Response

### 200

The captured payment.

- `payment` (PaymentResponse, required) — Hyperswitch payment_intent response. Loosely typed; extra Hyperswitch fields pass through.

## Errors

### 400 Bad Request Error

Invalid request (e.g. malformed JSON, missing required field, amount below minimum).

- `error` (ErrorResponseError, required)

### 401 Unauthorized Error

Missing or invalid API key.

- `error` (ErrorResponseError, required)

### 500 Internal Server Error

Unexpected server error.

- `error` (ErrorResponseError, required)

## Types

### PaymentResponse

Hyperswitch payment_intent response. Loosely typed; extra Hyperswitch fields pass through.

- `payment_id` (string, required)
- `status` (string, required) — e.g. requires_payment_method, requires_confirmation, succeeded, processing, cancelled.
- `amount` (integer, required) — Minor units (cents).
- `currency` (string, required)
- `client_secret` (string, optional) — Mounted by the browser SDK to confirm with the card.
- `merchant_id` (string, optional)
- `connector` (string, optional) — Connector chosen by Hyperswitch (may be null).
- `metadata` (map from string to any, optional) — Includes server-stamped mvs_org_id / mvs_org_slug.

### ErrorResponseError

- `code` (string, required) — e.g. UNAUTHORIZED, FORBIDDEN, ERROR.
- `message` (string, required)
- `details` (map from string to any, optional)

## Examples

**Request**

```json
{
  "amount_to_capture": 2000
}
```

**Response**

```json
{
  "payment": {
    "payment_id": "string",
    "status": "string",
    "amount": 1,
    "currency": "string",
    "client_secret": "string",
    "merchant_id": "string",
    "connector": "string",
    "metadata": {}
  }
}
```

**SDK Code**

```python Payments_capturePayment_example
import requests

url = "https://pay.mvscloud.com/api/authorizations/id/capture"

payload = { "amount_to_capture": 2000 }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Payments_capturePayment_example
const url = 'https://pay.mvscloud.com/api/authorizations/id/capture';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"amount_to_capture":2000}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Payments_capturePayment_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://pay.mvscloud.com/api/authorizations/id/capture"

	payload := strings.NewReader("{\n  \"amount_to_capture\": 2000\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Payments_capturePayment_example
require 'uri'
require 'net/http'

url = URI("https://pay.mvscloud.com/api/authorizations/id/capture")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"amount_to_capture\": 2000\n}"

response = http.request(request)
puts response.read_body
```

```java Payments_capturePayment_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://pay.mvscloud.com/api/authorizations/id/capture")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"amount_to_capture\": 2000\n}")
  .asString();
```

```php Payments_capturePayment_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://pay.mvscloud.com/api/authorizations/id/capture', [
  'body' => '{
  "amount_to_capture": 2000
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Payments_capturePayment_example
using RestSharp;

var client = new RestClient("https://pay.mvscloud.com/api/authorizations/id/capture");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"amount_to_capture\": 2000\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Payments_capturePayment_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["amount_to_capture": 2000] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://pay.mvscloud.com/api/authorizations/id/capture")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```