> ## Documentation Index
> Fetch the complete documentation index at: https://docs-mx.taxo.ws/llms.txt
> Use this file to discover all available pages before exploring further.

# Create extraction

> Start a new process for extracting tax documents from SAT

## Description

This endpoint starts a process for extracting tax documents from SAT. Extraction is an asynchronous process that can take several minutes depending on the volume of documents.

> [!NOTE]
>
> The extraction process is asynchronous. Use the returned `publicId` to check status or configure webhooks to receive notifications.

## Request

**subject** `object` *required*

Information of the taxpayer from whom to extract documents

**Propiedades de subject**

**identifier** `string` *required*

Taxpayer's RFC (13 characters for legal entities, 10 for individuals)

**name** `string`

Company name or taxpayer name (optional)

**credentials** `object` *required*

Credentials to access SAT

**Propiedades de credentials**

**type** `string` *required*

Credential type. Allowed values: `CIEC`, `FIEL`

**password** `string` *required*

Password encoded in base64

**privateKey** `string`

Private key in base64 (required only for FIEL)

**certificate** `string`

Certificate in base64 (required only for FIEL)

**options** `object` *required*

Extraction options

**Propiedades de options**

**informationType** `string` *required*

Type of information to extract: `INVOICE`, `TAX_STATUS`, `TAX_RETENTION`

**period** `object` *required*

Time period for extraction

**period properties**

**from** `string` *required*

Start date in YYYY-MM-DD format

**to** `string` *required*

End date in YYYY-MM-DD format

**direction** `string`

For invoices: `RECEIVED` or `ISSUED`. Default is `RECEIVED`

**filters** `object`

Optional filters for extraction

**Propiedades de filters**

**emitters** `array`

List of issuer RFCs to filter documents

**receivers** `array`

List of receiver RFCs to filter documents

**minAmount** `number`

Minimum amount of documents

**maxAmount** `number`

Maximum amount of documents

## Response

**publicId** `string`

Unique extraction ID for subsequent queries

**status** `string`

Current status: `PENDING`, `PROCESSING`, `COMPLETED`, `FAILED`

**createdAt** `string`

Creation timestamp in ISO 8601 format

**options** `object`

Copy of the options sent in the request

**subject** `object`

Processed taxpayer information

**Propiedades de subject**

**identification** `string`

Taxpayer's RFC

**fullName** `string`

Full name obtained from SAT

**personType** `string`

Person type: `MORAL` or `FISICA`

**discoveryCount** `number`

Number of documents found (0 initially)

**completedCount** `number`

Number of documents processed successfully

**failedCount** `number`

Number of documents that failed to process

## Examples

```bash cURL theme={null}
curl -X POST "https://api.taxo.co/v1/extractions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": {
      "identifier": "ABC010101ABC",
      "name": "Empresa ABC S.A. de C.V."
    },
    "credentials": {
      "type": "CIEC",
      "password": "bXlQYXNzd29yZDEyM0A="
    },
    "options": {
      "informationType": "INVOICE",
      "period": {
        "from": "2024-01-01",
        "to": "2024-12-31"
      },
      "direction": "RECEIVED"
    },
    "filters": {
      "emitters": ["XYZ020202XYZ"],
      "minAmount": 1000
    }
  }'
```

```javascript Node.js theme={null}
const response = await fetch('https://api.taxo.co/v1/extractions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.TAXO_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    subject: {
      identifier: 'ABC010101ABC',
      name: 'Empresa ABC S.A. de C.V.'
    },
    credentials: {
      type: 'CIEC',
      password: Buffer.from('myPassword123@').toString('base64')
    },
    options: {
      informationType: 'INVOICE',
      period: {
        from: '2024-01-01',
        to: '2024-12-31'
      },
      direction: 'RECEIVED'
    },
    filters: {
      emitters: ['XYZ020202XYZ'],
      minAmount: 1000
    }
  })
});

const extraction = await response.json();
console.log('Extracción creada:', extraction.publicId);
```

```python Python theme={null}
import requests
import base64

# Encode password
password_b64 = base64.b64encode('myPassword123@'.encode()).decode()

payload = {
    'subject': {
        'identifier': 'ABC010101ABC',
        'name': 'Empresa ABC S.A. de C.V.'
    },
    'credentials': {
        'type': 'CIEC',
        'password': password_b64
    },
    'options': {
        'informationType': 'INVOICE',
        'period': {
            'from': '2024-01-01',
            'to': '2024-12-31'
        },
        'direction': 'RECEIVED'
    },
    'filters': {
        'emitters': ['XYZ020202XYZ'],
        'minAmount': 1000
    }
}

response = requests.post(
    'https://api.taxo.co/v1/extractions',
    json=payload,
    headers={
        'Authorization': f'Bearer {os.environ["TAXO_API_KEY"]}',
        'Content-Type': 'application/json'
    }
)

extraction = response.json()
print(f'Extraction created: {extraction["publicId"]}')
```

```java Java theme={null}
// Usando Spring RestTemplate
RestTemplate restTemplate = new RestTemplate();

Map<String, Object> payload = new HashMap<>();
payload.put("subject", Map.of(
    "identifier", "ABC010101ABC",
    "name", "Empresa ABC S.A. de C.V."
));

payload.put("credentials", Map.of(
    "type", "CIEC",
    "password", Base64.getEncoder().encodeToString("myPassword123@".getBytes())
));

payload.put("options", Map.of(
    "informationType", "INVOICE",
    "period", Map.of(
        "from", "2024-01-01",
        "to", "2024-12-31"
    ),
    "direction", "RECEIVED"
));

HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + System.getenv("TAXO_API_KEY"));
headers.setContentType(MediaType.APPLICATION_JSON);

HttpEntity<Map<String, Object>> request = new HttpEntity<>(payload, headers);

ResponseEntity<Map> response = restTemplate.postForEntity(
    "https://api.taxo.co/v1/extractions",
    request,
    Map.class
);

System.out.println("Extraction created: " + response.getBody().get("publicId"));
```

## Successful response

```json theme={null}
{
  "publicId": "JOB20250104123456789A",
  "status": "PENDING",
  "createdAt": "2025-01-04T12:34:56.789Z",
  "options": {
    "informationType": "INVOICE",
    "period": {
      "from": "2024-01-01",
      "to": "2024-12-31"
    },
    "direction": "RECEIVED"
  },
  "subject": {
    "identification": "ABC010101ABC",
    "fullName": "Empresa ABC S.A. de C.V.",
    "personType": "MORAL"
  },
  "discoveryCount": 0,
  "completedCount": 0,
  "failedCount": 0
}
```

## Common errors

```json Error 400 - Invalid RFC theme={null}
{
  "error": {
    "code": "INVALID_RFC",
    "message": "The provided RFC does not have a valid format",
    "details": {
      "field": "subject.identifier",
      "provided": "ABC01010",
      "expected": "RFC of 10 or 13 characters"
    }
  }
}
```

```json Error 401 - Incorrect SAT credentials theme={null}
{
  "error": {
    "code": "INVALID_CREDENTIALS",
    "message": "The CIEC credentials are incorrect",
    "details": {
      "field": "credentials.password",
      "hint": "Verify that the password is encoded in base64"
    }
  }
}
```

```json Error 429 - Rate limit exceeded theme={null}
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "You have exceeded the limit of 10 extractions per hour",
    "details": {
      "limit": 10,
      "window": "1 hour",
      "resetAt": "2025-01-04T14:00:00Z"
    }
  }
}
```

## Important notes

> [!WARNING]
>
> **Passwords:** Always encode passwords in base64 before sending them. Plain text passwords will be rejected.

> [!TIP]
>
> **Large periods:** For date ranges greater than 3 months, consider splitting the extraction into multiple requests for better performance.

> [!NOTE]
>
> **Asynchronous status:** Once the extraction is created, use the [Check status](https://docs-mx.taxo.ws/api-reference/taxo-b2b/endpoints/get-extraction) endpoint to monitor progress.


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