# Cost centers

> Split an issuer's income and expenses by job site, project, branch or department: put each invoice in a cost center and filter by it.

A cost center is a part of the business the issuer wants to see separately: a job site, a project, a branch, a department or a vehicle. Each invoice, the one you stamp with the API or the one that comes from SAT, can go in one, and in the app **Reportes** shows how much came in, how much went out and what each one left. It's a Fiscalisto label: it doesn't change the CFDI, its taxes or what SAT sees. They're the same as **Ajustes › Centros de costo** in the app, including the per-customer or per-supplier rules created there.

## Create a cost center

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/cost_centers \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Obra Norte", "code": "CC-01" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const costCenter = await fiscalisto.costCenters.create({ name: "Obra Norte", code: "CC-01" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

cost_center = fiscalisto.cost_centers.create({"name": "Obra Norte", "code": "CC-01"})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$costCenter = $fiscalisto->costCenters->create(['name' => 'Obra Norte', 'code' => 'CC-01']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	costCenter, err := client.CostCenters.Create(ctx, &fiscalisto.CreateCostCenterParams{
		Name: "Obra Norte",
		Code: fiscalisto.String("CC-01"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(costCenter.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.CreateCostCenterParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var costCenter = fiscalisto.costCenters().create(new CreateCostCenterParams().setName("Obra Norte").setCode("CC-01"));
System.out.println(costCenter.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var costCenter = await fiscalisto.CostCenters.CreateAsync(new CreateCostCenterParams
{
    Name = "Obra Norte",
    Code = "CC-01",
});
```

Returns the cost center (`ccn_…`) with `invoices`, how many invoices it has. The name doesn't repeat within the issuer, regardless of case (another equal one returns `cost_center_exists`); `code` is optional, for the code your accounting uses. Up to 500 per issuer.

## Set it when invoicing

Send `cost_center` on the invoice:

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: avance-obra-norte-3" \
  -H "Content-Type: application/json" \
  -d '{
    "cost_center": "ccn_OufpKqnrvx9p1",
    "customer": { "tax_id": "ICV060329BY0", "legal_name": "INMOBILIARIA CVA", "tax_system": "601", "zip": "33826" },
    "payment_form": "03",
    "items": [{ "description": "Avance de obra 3", "product_key": "72141000", "unit_price": 250000 }]
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const invoice = await fiscalisto.invoices.create({
  cost_center: "ccn_OufpKqnrvx9p1",
  customer: {
    tax_id: "ICV060329BY0",
    legal_name: "INMOBILIARIA CVA",
    tax_system: "601",
    zip: "33826",
  },
  payment_form: "03",
  items: [
    {
      description: "Avance de obra 3",
      product_key: "72141000",
      unit_price: 250000,
    },
  ],
}, { idempotencyKey: "avance-obra-norte-3" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

invoice = fiscalisto.invoices.create({
    "cost_center": "ccn_OufpKqnrvx9p1",
    "customer": {
        "tax_id": "ICV060329BY0",
        "legal_name": "INMOBILIARIA CVA",
        "tax_system": "601",
        "zip": "33826",
    },
    "payment_form": "03",
    "items": [
        {
            "description": "Avance de obra 3",
            "product_key": "72141000",
            "unit_price": 250000,
        },
    ],
}, idempotency_key="avance-obra-norte-3")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$invoice = $fiscalisto->invoices->create([
    'cost_center' => 'ccn_OufpKqnrvx9p1',
    'customer' => [
        'tax_id' => 'ICV060329BY0',
        'legal_name' => 'INMOBILIARIA CVA',
        'tax_system' => '601',
        'zip' => '33826',
    ],
    'payment_form' => '03',
    'items' => [
        [
            'description' => 'Avance de obra 3',
            'product_key' => '72141000',
            'unit_price' => 250000,
        ],
    ],
], ['idempotency_key' => 'avance-obra-norte-3']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	invoice, err := client.Invoices.Create(ctx, &fiscalisto.InvoiceCreate{
		CostCenter: fiscalisto.String("ccn_OufpKqnrvx9p1"),
		Customer: fiscalisto.ObjectOf(fiscalisto.InvoiceCreateCustomer{
			TaxID:     "ICV060329BY0",
			LegalName: "INMOBILIARIA CVA",
			TaxSystem: "601",
			Zip:       "33826",
		}),
		PaymentForm: fiscalisto.String("03"),
		Items: []fiscalisto.InvoiceCreateItem{
			{
				Description: fiscalisto.String("Avance de obra 3"),
				ProductKey:  fiscalisto.String("72141000"),
				UnitPrice:   fiscalisto.Float64(250000),
			},
		},
	}, fiscalisto.WithIdempotencyKey("avance-obra-norte-3"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.InvoiceCreate;
import com.fiscalisto.model.InvoiceCreateCustomer;
import com.fiscalisto.model.InvoiceCreateItem;
import java.util.List;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = fiscalisto.invoices().create(new InvoiceCreate()
        .setCostCenter("ccn_OufpKqnrvx9p1")
        .setCustomer(new InvoiceCreateCustomer()
                .setTaxId("ICV060329BY0")
                .setLegalName("INMOBILIARIA CVA")
                .setTaxSystem("601")
                .setZip("33826"))
        .setPaymentForm("03")
        .setItems(List.of(
                new InvoiceCreateItem()
                        .setDescription("Avance de obra 3")
                        .setProductKey("72141000")
                        .setUnitPrice(250000)
        )), RequestOptions.idempotencyKey("avance-obra-norte-3"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = await fiscalisto.Invoices.CreateAsync(new InvoiceCreate
{
    CostCenter = "ccn_OufpKqnrvx9p1",
    Customer = new InvoiceCreateCustomer
    {
        TaxId = "ICV060329BY0",
        LegalName = "INMOBILIARIA CVA",
        TaxSystem = "601",
        Zip = "33826",
    },
    PaymentForm = "03",
    Items = new()
    {
        new()
        {
            Description = "Avance de obra 3",
            ProductKey = "72141000",
            UnitPrice = 250000,
        },
    },
}, new RequestOptions { IdempotencyKey = "avance-obra-norte-3" });
```

The invoice carries `cost_center` from the moment it's created. Its credit notes (`POST /v1/credit_notes`) take the same cost center on their own, so they subtract where the sale counted. An archived cost center can't be used: restore it or use another.

## Set, change or remove it later

A stamped invoice changes cost center with `POST /v1/invoices/{id}`; a SAT invoice (for example, an expense the issuer received) with `POST /v1/sat_invoices/{id}`. `null` removes it:

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/sat_invoices/sat_OufpKqnrvx9p7Bq \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "cost_center": "ccn_OufpKqnrvx9p1" }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const satInvoice = await fiscalisto.satInvoices.update("sat_OufpKqnrvx9p7Bq", { cost_center: "ccn_OufpKqnrvx9p1" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

sat_invoice = fiscalisto.sat_invoices.update("sat_OufpKqnrvx9p7Bq", {"cost_center": "ccn_OufpKqnrvx9p1"})
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$satInvoice = $fiscalisto->satInvoices->update('sat_OufpKqnrvx9p7Bq', ['cost_center' => 'ccn_OufpKqnrvx9p1']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	satInvoice, err := client.SatInvoices.Update(ctx, "sat_OufpKqnrvx9p7Bq", &fiscalisto.UpdateSatInvoiceParams{
		CostCenter: fiscalisto.String("ccn_OufpKqnrvx9p1"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(satInvoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.UpdateSatInvoiceParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var satInvoice = fiscalisto.satInvoices().update("sat_OufpKqnrvx9p7Bq", new UpdateSatInvoiceParams().setCostCenter("ccn_OufpKqnrvx9p1"));
System.out.println(satInvoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var satInvoice = await fiscalisto.SatInvoices.UpdateAsync("sat_OufpKqnrvx9p7Bq", new UpdateSatInvoiceParams
{
    CostCenter = "ccn_OufpKqnrvx9p1",
});
```

Payment complements and transfers don't carry a cost center (they return `parameter_invalid`). Only the label changes: the CFDI stays the same.

## Filter by cost center

`GET /v1/invoices` and `GET /v1/sat_invoices` accept `cost_center`: a `ccn_…`, or `none` for the ones that don't have one yet.

```bash tab="cURL"
curl -G https://api.fiscalisto.com/v1/sat_invoices \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -d cost_center=ccn_OufpKqnrvx9p1 \
  -d date_gte=2026-10-01
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

for await (const item of fiscalisto.satInvoices.list({
  cost_center: "ccn_OufpKqnrvx9p1",
  date_gte: "2026-10-01",
})) {
  console.log(item.id);
}
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

for item in fiscalisto.sat_invoices.list({
    "cost_center": "ccn_OufpKqnrvx9p1",
    "date_gte": "2026-10-01",
}):
    print(item["id"])
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

foreach ($fiscalisto->satInvoices->list([
    'cost_center' => 'ccn_OufpKqnrvx9p1',
    'date_gte' => '2026-10-01',
]) as $item) {
    echo $item['id'], "\n";
}
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	for item, err := range client.SatInvoices.ListAutoPaging(ctx, &fiscalisto.ListSatInvoicesParams{
		CostCenter: fiscalisto.String("ccn_OufpKqnrvx9p1"),
		DateGte:    fiscalisto.String("2026-10-01"),
	}) {
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println(item.ID)
	}
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.model.ListSatInvoicesParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

for (var item : fiscalisto.satInvoices().listAutoPaging(new ListSatInvoicesParams()
        .setCostCenter("ccn_OufpKqnrvx9p1")
        .setDateGte("2026-10-01"))) {
    System.out.println(item.getId());
}
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

await foreach (var item in fiscalisto.SatInvoices.ListAutoPagingAsync(new ListSatInvoicesParams
{
    CostCenter = "ccn_OufpKqnrvx9p1",
    DateGte = "2026-10-01",
}))
    Console.WriteLine(item.Id);
```

## Archive, merge or delete

`POST /v1/cost_centers/{id}` changes `name` and `code`; `"archived": true` archives it (no more invoices go in it, but its own keep it) and `false` restores it. `GET /v1/cost_centers` lists the active ones; with `include_archived=true`, the archived ones too.

`DELETE /v1/cost_centers/{id}` deletes it. With `move_to` (another `ccn_…`) its invoices and rules move to that one, which merges two into one; without it, its invoices are left without a cost center. Deleting can't be undone.

## In the app and with agents

What you do through the API shows in the app: **Facturas** filters by cost center and **Reportes** has **Resultado por centro de costo** and **Gastos por centro de costo**. With the [MCP](https://fiscalisto.com/en/docs/api/agentes), `centros_de_costo` lists them, `poner_centro_costo` puts invoices in one, `buscar_facturas` filters with `centro_costo` and `correr_reporte` groups with `por: centro`.
