# Retrieve tax retentions for a link

Retrieve tax retention information from a specific link. The maximum number of tax retentions that can be returned for a period is 500.

Endpoint: POST /api/tax-retentions/
Version: 1.223.0
Security: basicAuth

## Query parameters:

  - `omit` (string)
    Omit certain fields from being returned in the response. For more information, see our Filtering responses DevPortal article.

  - `fields` (string)
    Return only the specified fields in the response. For more information, see our Filtering responses DevPortal article.

## Request fields (application/json):

  - `link` (string, required)
    The link.id you want to retrieve information for.
    Example: "c81a1dea-6dd6-4999-8b9f-541ee8197058"

  - `date_from` (string, required)
    The date from which you want to start getting data for, in YYYY-MM-DD format.


⚠️ The value of date_from cannot be greater than date_to.
    Example: "2020-08-05"

  - `date_to` (string, required)
    The date you want to stop getting data for, in YYYY-MM-DD format.


⚠️ The value of date_to cannot be greater than today's date (in other words, no future dates).
    Example: "2020-10-05"

  - `type` (string, required)
    The type of tax retention in relation to the invoice (from the perspective of the Link owner).

- OUTFLOW relates to a tax retention for a sent invoice.
- INFLOW related to a tax retention for a received invoice.
    Enum: "OUTFLOW", "INFLOW"

  - `attach_xml` (boolean)
    When set to true, you will receive the XML invoice in the response.

  - `save_data` (boolean)
    Indicates whether or not to persist the data in Belvo. By default, this is set to true and we return a 201 Created response.

When set to false, the data won't be persisted and we return a 200 OK response.
    Example: true

## Response 200 fields (application/json):

  - `id` (string)
    Belvo's unique identifier for the current item.
    Example: "0d3ffb69-f83b-456e-ad8e-208d0998d71d"

  - `link` (string,null)
    The link.id the data belongs to.
    Example: "30cb4806-6e00-48a4-91c9-ca55968576c8"

  - `collected_at` (string, required)
    The ISO-8601 timestamp when the data point was collected.
    Example: "2022-02-09T08:45:50.406032Z"

  - `created_at` (string)
    The ISO-8601 timestamp of when the data point was created in Belvo's database.
    Example: "2022-02-09T08:45:50.406032Z"

  - `invoice_identification` (string,null, required)
    The fiscal institution's unique ID for the invoice that the tax retention relates to.
    Example: "def404af-5eef-4112-aa99-d1ec8493b89a"

  - `version` (string,null, required)
    The CFDI version of the tax retentions.
    Example: "1.0"

  - `code` (integer,null, required)
    The tax retention code. For more information, see our SAT Catalogs DevPortal article.
    Example: 25

  - `issued_at` (string,null, required)
    The ISO-8601 timestamp of when the tax retention was issued.
    Example: "2019-01-03T21:10:40.000Z"

  - `certified_at` (string,null, required)
    The ISO-8601 timestamp of when the tax retention was certified.
    Example: "2019-01-03T21:10:41.000Z"

  - `cancelled_at` (string,null, required)
    The ISO-8601 timestamp of when the tax retention was canceled (if applicable).

  - `sender_id` (string,null, required)
    The fiscal ID of the invoice sender.
    Example: "JKUF980404P0"

  - `sender_name` (string,null, required)
    The name of the invoice sender.
    Example: "Roberto Nunez Batman"

  - `receiver_nationality` (string,null, required)
    Whether the invoice receiver is a Mexican national or not. If the receiver is not considered a Mexican national, the retained taxes can be calculated differently. Possible values:
  - NATIONAL
  - FOREIGN
    Enum: "NATIONAL", "FOREIGN"

  - `receiver_id` (string,null, required)
    The fiscal ID of the invoice receiver.
    Example: "GYGK3207809L1"

  - `receiver_name` (string,null, required)
    The name of the invoice receiver.
    Example: "ACME LTD"

  - `total_invoice_amount` (number,null, required)
    The total amount of the invoice that the tax retention relates to.
    Example: 53249.8

  - `total_exempt_amount` (number,null, required)
    Total amount that is exempt from taxation.
    Example: 1000.8

  - `total_retained_amount` (number,null, required)
    Total tax retained.
    Example: 1550.7

  - `total_taxable_amount` (number,null, required)
    The total amount that can be taxed. Calculated as total_invoice_amount - total_exempt_amount.
    Example: 43249

  - `retention_breakdown` (array,null, required)
    A breakdown of the retained taxes.

  - `retention_breakdown.base_amount` (number,null, required)
    The base amount that was used to calculate the tax retention.
    Example: 0.03

  - `retention_breakdown.tax_type` (string,null, required)
    Optional attribute to indicate the type of tax withheld for the period or year according to the SAT catalog.
    Example: "01"

  - `retention_breakdown.retained_amount` (number,null, required)
    The amount retained.

  - `retention_breakdown.payment_status` (string,null, required)
    Indicates whether or not the tax has been paid or not. Can be either:
  - PAID
  - PROVISIONED
    Enum: "PAID", "PROVISIONED"

  - `xml` (string,null, required)
    The tax retention document in XML form.
    Example: "=XML-STRING="

## Response 403 fields (application/json):

  - `code` (string)
    A unique error code (access_to_resource_denied) that allows you to classify and handle the error programmatically.


ℹ️ Check our DevPortal for more information on how to handle 403 access_to_resource_denied.
    Example: "access_to_resource_denied"

  - `message` (string)
    A short description of the error. 


For access_to_resource_denied errors, the description is:
  
  - You don't have access to this resource..
    Example: "You don't have access to this resource."

  - `request_id` (string)
    A 32-character unique ID of the request (matching a regex pattern of: [a-f0-9]{32}). Provide this ID when contacting the Belvo support team to accelerate investigations.
    Example: "9e7b283c6efa449c9c028a16b5c249fb"

## Response 404 fields (application/json):

  - `code` (string)
    A unique error code (not_found) that allows you to classify and handle the error programmatically.
    Example: "not_found"

  - `message` (string)
    A short description of the error.


For not_found errors, the description is:

  - Not found
    Example: "Not found"

  - `request_id` (string)
    A 32-character unique ID of the request (matching a regex pattern of: [a-f0-9]{32}). Provide this ID when contacting the Belvo support team to accelerate investigations.
    Example: "9e7b283c6efa449c9c028a16b5c249fb"

## Response 408 fields (application/json):

  - `code` (string)
    A unique error code (request_timeout) that allows you to classify and handle the error programmatically.


ℹ️ Check our DevPortal for more information on how to handle 408 request_timeout errors.
    Example: "request_timeout"

  - `message` (string)
    A short description of the error. 


For request_timeout errors, the description is:
  
  - The request timed out, you can retry asking for less data by changing your query parameters.
    Example: "The request timed out, you can retry asking for less data by changing your query parameters"

  - `request_id` (string)
    A 32-character unique ID of the request (matching a regex pattern of: [a-f0-9]{32}). Provide this ID when contacting the Belvo support team to accelerate investigations.
    Example: "9e7b283c6efa449c9c028a16b5c249fb"

## Response 428 fields (application/json):

  - `code` (string)
    A unique error code (token_required) that allows you to classify and handle the error programmatically.
ℹ️ Check our DevPortal for more information on how to handle 428 token_required errors.
    Example: "token_required"

  - `message` (string)
    A short description of the error. 
For token_required errors, the description is:
  
  - A MFA token is required by the institution to login.
    Example: "A MFA token is required by the institution to login"

  - `request_id` (string)
    A 32-character unique ID of the request (matching a regex pattern of: [a-f0-9]{32}). Provide this ID when contacting the Belvo support team to accelerate investigations.
    Example: "9e7b283c6efa449c9c028a16b5c249fb"

  - `session` (string)
    A 32-character unique ID of the login session (matching a regex pattern of: [a-f0-9]{32}).
    Example: "2675b703b9d4451f8d4861a3eee54449"

  - `expiry` (integer)
    Session duration time in seconds.
    Example: 9600

  - `link` (string)
    Unique identifier created by Belvo, used to reference the current
Link.
    Example: "30cb4806-6e00-48a4-91c9-ca55968576c8"

  - `token_generation_data` (object)
    Details on how to generate the token.

  - `token_generation_data.instructions` (string)
    Instructions for token generation.
    Example: "Use this code to generate the token"

  - `token_generation_data.type` (string)
    Type of the data to generate the token (QR code, numeric
challenge).
    Example: "numeric"

  - `token_generation_data.value` (string)
    Value to use to generate the token.
    Example: "12345"

  - `token_generation_data.expects_user_input` (boolean)
    Indicates whether the user needs to provide input in order to complete the authentication.
When set to false, your user may need to:
- confirm the login on another device
- scan a QR code
You will still need to make a PATCH call to complete the request.
    Example: true

## Response 500 fields (application/json):

  - `code` (string)
    A unique error code (unexpected_error) that allows you to classify and handle the error programmatically.


ℹ️ Check our DevPortal for more information on how to handle 500 unexpected_error errors.
    Example: "unexpected_error"

  - `message` (string)
    A short description of the error. 


For unexpected_error errors, the description is:
  
  - Belvo is unable to process the request due to an internal system issue or to an unsupported response from an institution.
    Example: "Belvo is unable to process the request due to an internal system issue or to an unsupported response from an institution"

  - `request_id` (string)
    A 32-character unique ID of the request (matching a regex pattern of: [a-f0-9]{32}). Provide this ID when contacting the Belvo support team to accelerate investigations.
    Example: "9e7b283c6efa449c9c028a16b5c249fb"


