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

# Close Preview

> Tells whether `DELETE /organizations/:id` would delete the organization (no production CFDI) or close it (production CFDI retained until `retainedUntil`), and how many stamps or cancellations are still in progress (which block both).

Shows what [deleting](https://docs.timbrix.mx/api-reference/organizations/delete.md) an organization would do, without changing anything.

## Authentication

* **Authorization**: `Bearer <token>`

Only the organization **owner** can call this endpoint.

## Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `id` | string | Yes | Organization UUID |

## Response Fields

| Field | Type | Description |
| - | - | - |
| `mode` | string | `delete` if the organization will be erased, `close` if it has production CFDI and will be closed |
| `retainedUntil` | string \| null | Until when the CFDI will be retained (`null` when `mode` is `delete`) |
| `pending.stampAttempts` | number | Stamps still waiting for a PAC confirmation |
| `pending.cancellations` | number | Cancellations still in progress |
| `certificateWillBeDeleted` | boolean | `true` if the organization currently has a CSD that will be deleted when it is closed |
| `dataPurgeDays` | number | Days after closing when customers, products and settings are deleted (currently `90`) |

If `pending` has any non-zero value, closing fails with `409 ORGANIZATION_HAS_PENDING_OPERATIONS`.

## Example Request

```bash theme={null}
curl -X GET https://api.timbrix.mx/organizations/550e8400-e29b-41d4-a716-446655440000/close-preview \
  -H "Authorization: Bearer <your_token>"
```

```typescript theme={null}
import { Timbrix } from "@timbrix/sdk"

const client = new Timbrix({ bearerToken: "<your_token>" })

const preview = await client.organizations.closePreview(
  "550e8400-e29b-41d4-a716-446655440000"
)
```

## Example Response

```json theme={null}
{
  "mode": "close",
  "retainedUntil": "2033-01-01T05:59:59.000Z",
  "pending": { "stampAttempts": 0, "cancellations": 0 },
  "certificateWillBeDeleted": true,
  "dataPurgeDays": 90
}
```

`retainedUntil` is a UTC instant (ISO 8601). In this example, `2033-01-01T05:59:59.000Z` is 31 December 2032, 23:59:59 America/Mexico\_City time. Show it in that time zone, not in UTC.

## Common Errors

### 403 Forbidden

Only the owner can preview closing the organization.

### 404 Not Found

The organization does not exist.


## OpenAPI

````yaml GET /organizations/{id}/close-preview
openapi: 3.0.0
info:
  title: Timbrix API
  description: >-
    API de facturación electrónica CFDI 4.0 para México, con servidor OAuth2
    para gestionar organizaciones, miembros y webhooks. Compatible con agentes
    de IA — ver la extensión `x-ai-agent-friendly` en la raíz de esta spec.


    REST API with OAuth2 server for managing organizations, members, and
    webhooks.
  version: '1.0'
  contact: {}
servers: []
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
  - name: request-logs
    description: API request log
paths:
  /organizations/{id}/close-preview:
    get:
      tags:
        - organizations
      summary: Preview deleting or closing the organization (owner only)
      description: >-
        Tells whether `DELETE /organizations/:id` would delete the organization
        (no production CFDI) or close it (production CFDI retained until
        `retainedUntil`), and how many stamps or cancellations are still in
        progress (which block both).
      operationId: OrganizationsController_getClosePreview
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      responses:
        '200':
          description: Close preview.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClosePreviewResponseDto'
        '401':
          description: Authentication required. Provide a valid bearer token.
        '403':
          description: Access denied. Only the organization owner can see this.
        '404':
          description: Organization not found with the provided ID.
      security:
        - bearer: []
components:
  schemas:
    ClosePreviewResponseDto:
      type: object
      properties:
        mode:
          type: string
          enum:
            - delete
            - close
          example: close
          description: >-
            What `DELETE /organizations/:id` would do: `delete` (no production
            CFDI) or `close` (production CFDI are retained).
        retainedUntil:
          type: string
          nullable: true
          example: '2033-01-01T05:59:59.000Z'
          description: Retention date when `mode` is `close`; null otherwise.
        pending:
          description: >-
            Operations in progress. The organization cannot be closed or deleted
            while any count is above zero.
          allOf:
            - $ref: '#/components/schemas/ClosePreviewPendingDto'
      required:
        - mode
        - retainedUntil
        - pending
    ClosePreviewPendingDto:
      type: object
      properties:
        stampAttempts:
          type: number
          example: 0
          description: CFDI stamps still being confirmed with the PAC.
        cancellations:
          type: number
          example: 1
          description: Cancellations waiting for the SAT or the receiver.
      required:
        - stampAttempts
        - cancellations
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

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