> ## Documentation Index
> Fetch the complete documentation index at: https://developer.sandbox.co.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Crypto Tax P&L from a tradebook

> Submit a Crypto Tax P&L job, upload a JSON tradebook, poll its status, and download the result. Includes a synchronous calculation example.

Use the Crypto Tax P\&L API to calculate a workbook for a financial year. This recipe submits an asynchronous job and follows it through upload, polling, and download.

## Before you start

* Get an API key and an access token from [Authenticate](https://developer.sandbox.co.in/api-reference/authenticate.md).
* Prepare a [crypto tradebook](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/annexures/tradebook_crypto.md) as `crypto_tradebook.json`. The [sample tradebook](https://developer.sandbox.co.in/data/it/calculator/tax_pnl/crypto/crypto_tradebook.json) uses `FY 2025-26`.
* Set `API_KEY` and `ACCESS_TOKEN` in your shell. The authorization header takes the token without a `Bearer` prefix.

The examples use `FY 2025-26` and JSON output. Set `financial_year` to the year you want to calculate; `FY 2026-27` uses the Income-tax Act, 2025 calculation.

## Submit, upload, poll, and download

**1. Submit a job**

Call [Submit Job](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/endpoints/submit_job.md). Send the calculation parameters in the query string and leave the body empty.

> [accordion] Submit request
>
> ```bash theme={null}
> curl --request POST \
>   'https://api.sandbox.co.in/it/calculator/tax-pnl/crypto?input=tradebook&output=tradewise_tax_pnl&financial_year=FY%202025-26' \
>   --header "x-api-key: $API_KEY" \
>   --header "Authorization: $ACCESS_TOKEN" \
>   --header 'x-accept-type: application/json'
> ```

Save `data.job_id` as `JOB_ID` and `data.url` as `UPLOAD_URL`. The URL is for the input upload.

**2. Upload the tradebook**

[Upload the JSON workbook](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/endpoints/put_request.md) to the complete signed URL. The upload starts processing.

> [accordion] Upload request
>
> ```bash theme={null}
> curl --request PUT "$UPLOAD_URL" \
>   --header 'Content-Type: application/json' \
>   --data-binary '@crypto_tradebook.json'
> ```

**3. Poll the job**

Call [Poll Job](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/endpoints/job_status.md) with the saved job identifier.

> [accordion] Poll request
>
> ```bash theme={null}
> curl --get 'https://api.sandbox.co.in/it/calculator/tax-pnl/crypto' \
>   --data-urlencode "job_id=$JOB_ID" \
>   --header "x-api-key: $API_KEY" \
>   --header "Authorization: $ACCESS_TOKEN"
> ```

Continue polling while the status is `queued` or `in_progress`. A `created` job is waiting for its upload. Stop on `failed` and inspect `data.message` if present. When the status is `succeeded`, save `data.url` as `DOWNLOAD_URL`.

**4. Download the result**

[Download the output workbook](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/endpoints/get_response.md) with the URL from the successful poll response.

> [accordion] Download request
>
> ```bash theme={null}
> curl "$DOWNLOAD_URL" --output crypto_tax_pnl.json
> ```

Read the [Tax P\&L output reference](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/annexures/tradewise_tax_pnl_crypto.md) for the summary, spot, receipts, and futures tables.

## Calculate synchronously

The [sync endpoint](https://developer.sandbox.co.in/api-reference/it/calculator/tax_pnl/crypto/endpoints/sync.md) accepts the workbook directly and returns the JSON calculation in `data`.

> [accordion] Synchronous request
>
> ```bash theme={null}
> curl --request POST \
>   'https://api.sandbox.co.in/it/calculator/tax-pnl/crypto/sync?input=tradebook&output=tradewise_tax_pnl&financial_year=FY%202025-26' \
>   --header "x-api-key: $API_KEY" \
>   --header "Authorization: $ACCESS_TOKEN" \
>   --header 'Content-Type: application/json' \
>   --header 'x-accept-type: application/json' \
>   --data-binary '@crypto_tradebook.json'
> ```

For Excel output, use `x-accept-type: application/xlsx`. A synchronous response returns the download URL in `data`; an asynchronous job returns its download URL in `data.url` after it succeeds.

For `FY 2026-27`, use the asynchronous workflow for Excel. The synchronous Excel download link is currently unusable. Synchronous JSON is unaffected by this download issue.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.