PHPackages                             pittacusw/touchef - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. pittacusw/touchef

ActiveLibrary[API Development](/categories/api)

pittacusw/touchef
=================

Wrapper to connect a Laravel application to the Touchef API

v2.1(2mo ago)062↓91.7%LGPL-3.0-onlyPHPPHP  ^8.1

Since Aug 7Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/PittacusW/touchef-wrapper)[ Packagist](https://packagist.org/packages/pittacusw/touchef)[ RSS](/packages/pittacusw-touchef/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

pittacusw/touchef
=================

[](#pittacuswtouchef)

Small Laravel wrapper around the Touchef API for Chilean electronic invoicing workflows.

It provides:

- A `Touchef` service class for the Touchef HTTP API
- Laravel service provider + facade auto-discovery
- Config driven credentials via `TOUCHEF_RUT` and `TOUCHEF_TOKEN`
- Publishing for package config and the bundled Codex agent skill

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9.23, 12.x, or 13.x

Installation
------------

[](#installation)

```
composer require pittacusw/touchef
```

Publish the package config if you want a local config file:

```
php artisan vendor:publish --tag=touchef-config
```

Add your credentials to `.env`:

```
TOUCHEF_RUT=76111111-1
TOUCHEF_TOKEN=
```

Usage
-----

[](#usage)

### Resolve from the container

[](#resolve-from-the-container)

```
use Pittacusw\Touchef\Touchef;

$touchef = app(Touchef::class);
```

### Use the facade

[](#use-the-facade)

```
use Touchef;

$business = Touchef::info();
```

### Instantiate directly

[](#instantiate-directly)

```
use Pittacusw\Touchef\Touchef;

$touchef = new Touchef();

// Override the configured RUT for this runtime instance.
$touchef = new Touchef('76123456-7');
```

Authentication
--------------

[](#authentication)

```
$touchef->login('your-password');

$token = $touchef->refresh();

$touchef->logout();
```

`login()` and `refresh()` update the in-memory config token and also persist `TOUCHEF_TOKEN` to `.env` when that file exists. `login()` also persists the active `TOUCHEF_RUT`.

Common operations
-----------------

[](#common-operations)

### Tenant and reference data

[](#tenant-and-reference-data)

```
$info = $touchef->info();
$counties = $touchef->counties();
$activities = $touchef->economic_activities();
$lookup = $touchef->get_data('12345678-9');
```

### Sales

[](#sales)

```
$sales = $touchef->sales(2025, 3);
$summary = $touchef->sales_summary(2025, 3);
$sale = $touchef->sale('uuid-value');
$byNumber = $touchef->show_by_number(33, 1200);
$track = $touchef->track_id(77);
$siiStatus = $touchef->sii_status(77);
$providerStatus = $touchef->provider_status(77);
$pdf = $touchef->get_pdf(33, 1200);

$touchef->send_email(1200, 33);
```

### Create a document

[](#create-a-document)

```
$document = $touchef->create_document(
    document_type: 33,
    issued_at: '2025-03-15',
    lines: [[
        'name' => 'Servicio',
        'quantity' => 1,
        'unit_price' => 10000,
    ]],
    mode: 'issue',
    receiver: [
        'rut' => '98765432-1',
        'name' => 'Cliente SpA',
        'activity' => 'Servicios',
        'address' => 'Av. Siempre Viva 123',
        'county' => 'Santiago',
    ],
    payment: [
        'due_date' => '2025-04-15',
    ],
    notifications: ['facturacion@cliente.cl'],
);
```

Optional payload sections supported by `create_document()`:

- `receiver`
- `global_adjustments`
- `references`
- `transport`
- `payment`
- `notifications`

### Queue documents

[](#queue-documents)

```
$queued = $touchef->queue_documents([
    [
        'document_type' => 33,
        'issued_at' => '2025-03-15',
        'receiver' => [
            'rut' => '98765432-1',
            'name' => 'Cliente SpA',
            'activity' => 'Servicios',
            'address' => 'Av. Siempre Viva 123',
            'county' => 'Santiago',
        ],
        'lines' => [[
            'name' => 'Servicio',
            'quantity' => 1,
            'unit_price' => 10000,
        ]],
    ],
]);
```

### Expenses

[](#expenses)

```
$expenses = $touchef->expenses(2025, 3);
$summary = $touchef->expenses_summary(2025, 3);
$expense = $touchef->expense('uuid-value');
$pending = $touchef->pending();

$accepted = $touchef->manage_expense(42, 'ACD');
```

Supported expense management codes:

- `ACD`
- `RCD`
- `RFP`
- `RFT`

### Business management

[](#business-management)

```
$updated = $touchef->update_client(
    county: 1,
    economic_activity: 5,
    name: 'Mi Empresa SpA',
    rut: '12345678-9',
    activity: 'Servicios de software',
    address: 'Av. Providencia 1234',
    resolution_date: '2020-01-15',
    resolution_number: 80,
    email: 'admin@miempresa.cl',
);

$created = $touchef->create_client(
    county_id: 1,
    economic_activity_id: 5,
    name: 'Nueva Empresa SpA',
    rut: '12345678-9',
    activity: 'Servicios de software',
    address: 'Av. Providencia 1234',
    resolution_date: '2020-01-15',
    resolution_number: 80,
    email: 'admin@nuevaempresa.cl',
    password: 'securepassword123',
    website: 'https://nuevaempresa.cl',
);
```

### Certificates and folios

[](#certificates-and-folios)

```
$certificate = $touchef->certificate();
$updated = $touchef->update_certificate(storage_path('certs/company.pfx'), 'pfx-password');
$caf = $touchef->caf();
```

Response behavior
-----------------

[](#response-behavior)

Most wrapper methods expect the API to return a JSON object containing `records` and will return that value directly.

The exception is `queue_documents()`, which returns the full decoded object and expects a `queued` property.

Failed HTTP responses abort with the response status code.

Agent skill publishing
----------------------

[](#agent-skill-publishing)

This package also ships with a Codex skill for Touchef-specific workflows. You can publish it with:

```
php artisan vendor:publish --tag=touchef-agent-skill
```

Or via the dedicated command:

```
php artisan touchef:install-agent-skill
```

That publishes the skill into:

```
.agents/skills/touchef

```

Testing
-------

[](#testing)

```
composer test
```

Notes
-----

[](#notes)

- The wrapper sends the `business` header using the configured RUT formatted by `freshwork/chilean-bundle`.
- The bearer token is only attached when `TOUCHEF_TOKEN` is present.
- `update_certificate()` now throws a `RuntimeException` if the provided certificate file cannot be read.

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~335 days

Total

5

Last Release

75d ago

Major Versions

v1.2 → v2.12026-04-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/97c33f4ec07e9426c6c66fe4d0b0840a31823e10992dcd1824bc91982d043ea3?d=identicon)[contal](/maintainers/contal)

---

Top Contributors

[![PittacusW](https://avatars.githubusercontent.com/u/5810290?v=4)](https://github.com/PittacusW "PittacusW (13 commits)")

---

Tags

laravelchilesiifacturacion-electronicadtetouchef

### Embed Badge

![Health badge](/badges/pittacusw-touchef/health.svg)

```
[![Health](https://phpackages.com/badges/pittacusw-touchef/health.svg)](https://phpackages.com/packages/pittacusw-touchef)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.5M916](/packages/statamic-cms)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k36.4M126](/packages/darkaonline-l5-swagger)[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k13.5M59](/packages/knuckleswtf-scribe)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

72287.1k1](/packages/mozex-anthropic-laravel)[libredte/libredte-api-client

Cliente para realizar la integración con los servicios web de LibreDTE desde PHP.

171.0k](/packages/libredte-libredte-api-client)[yakovenko/laravel-lighthouse-graphql-multi-schema

A Laravel package that provides multi-schema support for Lighthouse GraphQL.

17112.5k](/packages/yakovenko-laravel-lighthouse-graphql-multi-schema)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
