> ## 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.

# Prepare Form 138 TDS returns

> Check salary TDS data for potential notices and generate the Form 138 TXT file for validation and filing.

Prepare a Form 138 return (formerly Form 24Q) by reviewing your salary payment data, then generating a TXT file with the TDS Reports API. This recipe covers Q1 to Q3. After generating the TXT file, validate it with FVU and file the return.

## Before you start

* Get a Sandbox API key and access token using the [Quickstart guide](https://developer.sandbox.co.in/guides/get-started/quickstart.md).
* Use Bash, cURL, and jq for the examples. Set `BASE_URL`, `API_KEY`, and `ACCESS_TOKEN` for the same environment.

The examples use synthetic TAN `AHMA00000C`, `TY 2026-27`, and `Q1`. Use the workbook's TAN in each job request. The job's `tax_year` and `quarter` set the Potential Notices filing deadline. The workbook has no tax year or quarter fields.

**1. Create a Potential Notices job**

Call [Submit Job](https://developer.sandbox.co.in/api-reference/tds/analytics/tds-analytics/endpoints/submit_job.md) for Form 138. Save `data.job_id` and `data.input_json_url`. The job starts as `created` and waits for your workbook.

> [accordion] Create the Potential Notices job
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   --request POST "$BASE_URL/tds/analytics/potential-notices" \
>   --header "authorization: $ACCESS_TOKEN" \
>   --header "x-api-key: $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "@entity": "in.co.sandbox.tds.analytics.potential_notice.request",
>     "tax_year": "TY 2026-27",
>     "form": "138",
>     "quarter": "Q1",
>     "tan": "AHMA00000C"
>   }' --output notice-job.json
> NOTICE_JOB_ID=$(jq -er '.data.job_id' notice-job.json)
> NOTICE_UPLOAD_URL=$(jq -er '.data.input_json_url' notice-job.json)
> printf 'Potential Notices job ID: %s\n' "$NOTICE_JOB_ID"
> ```

**2. Upload the Potential Notices workbook**

Prepare your [Form 138 Potential Notices workbook](https://developer.sandbox.co.in/api-reference/tds/analytics/tds-analytics/put_request/form138.md) and save it as `form138-notices.json`. The [sample input](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_workbook.data.json) and [JSON schema](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_workbook.schema.json) show its structure. Upload the file itself as the request body. Signed upload and download URLs do not need Sandbox authentication headers.

> [accordion] Upload the Potential Notices Sheet JSON
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   --request PUT "$NOTICE_UPLOAD_URL" \
>   --header 'Content-Type: application/json' \
>   --data-binary @form138-notices.json
> ```

Potential Notices adds the payee's boolean `is_pan_operative` and the challan's `utilized_amount`, which records credit used outside this workbook. Prepare the Potential Notices and Reports workbooks against their own schemas. Date fields use Unix milliseconds.

**3. Fetch and review the Potential Notices report**

Call [Poll Job](https://developer.sandbox.co.in/api-reference/tds/analytics/tds-analytics/endpoints/poll_job.md) with `NOTICE_JOB_ID`. Repeat while the status is `created`, `queued`, or `in_progress`, waiting between requests and applying a timeout in your integration. Stop on `succeeded` or `failed`. A 200 response means the polling request succeeded. Read `data.status` to find whether the job has finished.

> [accordion] Fetch the Potential Notices job status
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   "$BASE_URL/tds/analytics/potential-notices?job_id=$NOTICE_JOB_ID" \
>   --header "authorization: $ACCESS_TOKEN" \
>   --header "x-api-key: $API_KEY" \
>   --output notice-result.json
> jq '.data | {job_id, status, message, output_json_url, output_excel_url, validation_json_url, validation_excel_report_url}' notice-result.json
> ```

On `succeeded`, download `output_json_url` or `output_excel_url`. A successful job can still contain potential notices. Read the [Form 138 output reference](https://developer.sandbox.co.in/api-reference/tds/analytics/tds-analytics/get_response/form138.md) for report fields and calculation limits.

> [accordion] Download a successful assessment
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   "$(jq -er '.data.output_json_url' notice-result.json)" --output form138-notices-output.json
> curl --fail-with-body --silent --show-error \
>   "$(jq -er '.data.output_excel_url' notice-result.json)" --output form138-notices-output.xlsx
> ```

In `potential_notices_summary_table`, `Y` means the assessment found a notice for a payment, challan, or the statement. `N` means the category is fully assessed with no notice. `N/A` means it could not be fully assessed and no assessed row establishes a notice. Use summary balances when reviewing amounts. Adding detail amounts to summary amounts counts the same charges twice.

Form 138 does not assess salary short deduction. Review salary deductions separately.

On `failed`, check `message`. Workbook row errors return `validation_json_url` and `validation_excel_report_url` when available. Other failures, including an invalid workbook structure or a TAN mismatch, may have no validation files.

> [accordion] Download workbook validation errors
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   "$(jq -er '.data.validation_json_url' notice-result.json)" --output form138-validation.json
> curl --fail-with-body --silent --show-error \
>   "$(jq -er '.data.validation_excel_report_url' notice-result.json)" --output form138-validation.xlsx
> ```

Inspect the samples: [output JSON](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_output.json), [output Excel](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_output.xlsx), [validation JSON](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_validation.json), and [validation Excel](https://developer.sandbox.co.in/data/tds/analytics/forms/form138_validation.xlsx). The validation examples use `invalid` as the first payee's PAN. The JSON identifies the field and row, and Excel annotates cell `B3` in `payee_sheet`.

Correct your source data and submit a new job when needed. Download links expire after 24 hours. Poll again for fresh links. When you are ready, use the corrected data to prepare the Reports workbook for TXT generation.

**4. Create a TXT job**

Call [Submit Job](https://developer.sandbox.co.in/api-reference/tds/reports/tds-reports/endpoints/submit_job.md). Save the Reports job ID and its `json_url`. These belong to the TXT job, separate from the Potential Notices job.

> [accordion] Submit the Form 138 request
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   --request POST "$BASE_URL/tds/reports/txt" \
>   --header "authorization: $ACCESS_TOKEN" \
>   --header "x-api-key: $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data '{
>     "@entity": "in.co.sandbox.tds.reports.request",
>     "tax_year": "TY 2026-27",
>     "form": "138",
>     "quarter": "Q1",
>     "tan": "AHMA00000C"
>   }' --output txt-job.json
> TXT_JOB_ID=$(jq -er '.data.job_id' txt-job.json)
> TXT_UPLOAD_URL=$(jq -er '.data.json_url' txt-job.json)
> printf 'TXT job ID: %s\n' "$TXT_JOB_ID"
> ```

**5. Upload the Reports workbook**

Prepare the [Form 138 Reports workbook](https://developer.sandbox.co.in/api-reference/tds/reports/tds-reports/salary_payments.md). The [Reports sample](https://developer.sandbox.co.in/data/tds/reports/forms/form138_workbook.data.json) and [JSON schema](https://developer.sandbox.co.in/data/tds/reports/forms/form138_workbook.schema.json) show the required structure. Save your Reports Sheet JSON as `form138.json`, then upload it to the returned upload address. Send the JSON file itself as the request body.

> [accordion] Upload Form 138 Sheet JSON
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   --request PUT "$TXT_UPLOAD_URL" \
>   --header 'Content-Type: application/json' \
>   --data-binary @form138.json
> ```

**6. Poll for the TXT file**

Call [Poll Job](https://developer.sandbox.co.in/api-reference/tds/reports/tds-reports/endpoints/poll_job.md) with `TXT_JOB_ID`. Repeat the request while processing continues, waiting between requests. Stop on `succeeded` or `failed` and apply a timeout in your integration.

> [accordion] Fetch the TXT job status
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   "$BASE_URL/tds/reports/txt?job_id=$TXT_JOB_ID" \
>   --header "authorization: $ACCESS_TOKEN" \
>   --header "x-api-key: $API_KEY" \
>   --output txt-result.json
> jq '.data | {job_id, status, txt_url, validation_report_url}' txt-result.json
> ```

On `succeeded`, download `data.txt_url`. On `failed`, download `data.validation_report_url` if present. Correct the workbook and create a new TXT job.

> [accordion] Download the generated TXT file
>
> ```bash theme={null}
> curl --fail-with-body --silent --show-error \
>   "$(jq -er '.data.txt_url' txt-result.json)" --output form-138.txt
> ```

## Validate and file the return

Follow [File Form 138 TDS returns](https://developer.sandbox.co.in/recipes/tds/form-138/file-form-138.md) to obtain the CSI file, run FVU validation, and e-file the return. A generated TXT file still needs FVU validation before filing.


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