Why do customer requests end up in the core product?
A large customer signs, and the contract includes an integration with their ERP. Another wants a weekly export in a format only their finance team uses. A third needs an API endpoint shaped around their own data warehouse.
Each request is reasonable on its own. Built into the core product, though, every one of them adds a code path most customers never touch, a credential to store, and a deploy to coordinate with the rest of the platform.
Running them in your own cloud has a cost too. Someone has to provision the function, the queue and the scheduler for each one, and then keep them patched and monitored for as long as the contract runs.
A coding agent can now write most of this code in an afternoon. The hours go into finding somewhere to run it, and into looking after it for the length of the contract.
Inside your product, or beside it
| Built into your core product or cloud | Codehooks |
|---|---|
| Customer-specific code paths in the main codebase | Your product stays the same for every customer |
| A function, queue and scheduler to provision per request | No infrastructure to set up: routes, queues, cron and a database come with every project |
| Each customer integration is built from scratch | Deploy the same code to a new customer space and change the settings |
| Customer credentials stored next to your production secrets | Encrypted environment variables per space |
| Changes wait for the core release cycle | Deploy one integration in seconds, on its own schedule |
| Failures land in the same alerts as your product | Logs, queue status and stored errors per integration |
One customer's integration in one file
Your product sends an event. A worker pushes it into the customer's ERP, a weekly job retries failures and builds a report, and the customer's dashboard reads that report through its own API route.
import { app, Datastore } from 'codehooks-js';
// Your product posts events here with an API token
// (coho add-token), so the default auth check applies
app.post('/events', async (req, res) => {
const conn = await Datastore.open();
const event = await conn.insertOne('events', {
...req.body,
receivedAt: new Date().toISOString(),
pushed: false,
});
await conn.enqueue('push-to-erp', { id: event._id });
res.status(202).end();
});
// Maps your data model to this customer's ERP
app.worker('push-to-erp', async (req, res) => {
const conn = await Datastore.open();
const { id } = req.body.payload;
const event = await conn.findOneOrNull('events', id);
try {
const r = await fetch(`${process.env.ERP_URL}/invoices`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.ERP_TOKEN}`,
},
body: JSON.stringify(toErpInvoice(event)),
});
if (!r.ok) throw new Error(`ERP replied ${r.status}`);
await conn.updateOne('events', id, { $set: { pushed: true } });
} catch (err) {
// Stays unpushed, so the Monday job queues it again
await conn.updateOne('events', id, { $set: { lastError: String(err) } });
}
res.end();
});
// Mondays at 07:00: retry failures and build the weekly report
app.job('0 7 * * 1', async (req, res) => {
const conn = await Datastore.open();
await conn.enqueueFromQuery('events', { pushed: false }, 'push-to-erp');
const since = new Date(Date.now() - 7 * 864e5).toISOString();
const events = await conn
.getMany('events', { receivedAt: { $gt: since } })
.toArray();
await conn.insertOne('reports', {
week: since,
invoices: events.length,
total: events.reduce((sum, e) => sum + (e.amount || 0), 0),
});
res.end();
});
// The customer's dashboard reads this with a read-only token
app.get('/reports/latest', async (req, res) => {
const conn = await Datastore.open();
const [latest] = await conn
.getMany('reports', {}, { sort: { week: -1 }, limit: 1 })
.toArray();
res.json(latest || {});
});
export default app.init();
How does one integration become a template for the next?
Keep the integration in its own repository. When the next customer asks for the same thing, add a space for them, set their credentials and deploy the same code. The parts that change between customers (the address of their system, their token and how your fields map to theirs) live in environment variables and a mapping module, so everything else is shared and tested already.
# A second customer wants the same ERP integration
coho add globex
# Their endpoint and credentials, stored on their space only
coho set-env ERP_URL https://erp.globex.example --space globex
coho set-env ERP_TOKEN <their-token> --encrypted --space globex
# Same code, their own data, tokens and logs
coho deploy --space globex
Questions SaaS teams ask first
Including where this sits next to the cloud you already run
Does this replace our existing cloud setup?
How do we keep one customer separate from another?
coho add and deploy to it with coho use and coho deploy. If you have many small customers on the same integration, one space with a customer ID on every record and per-customer settings in the database is simpler (extra spaces are an add-on beyond what your plan includes, so this also keeps the count down).Where do the customer's credentials live?
coho set-env and stored encrypted when you pass --encrypted. Your code reads them with process.env. They're kept apart from your own production secrets, which matters when a customer rotates a key or the contract ends and you need to remove everything that belongs to them.Can the customer see the reports or call the API directly?
coho add-token --readonly and give it to their dashboard or their data team. If your product already issues JWTs from a provider with a JWKS endpoint, coho jwks makes the same logins work against these routes. You can also serve a small dashboard from the same project, since frontend hosting is included.What happens when the customer system is down?
maxRetries setting per step.Where is the data stored?
Built with a coding agent
Let the agent deploy what it writes
A coding agent can write a customer integration from their API docs and a sample of your data in an afternoon. What usually slows it down is everything after that: where the code is deployed, where the customer's credentials go, and who notices when it breaks.
With Codehooks the agent can do the deploy too. It runs coho prompt for the API reference, writes the code, deploys to the customer's space with coho deploy, and reads coho log to check the first events. You review the change in a pull request like any other.
An agent can write the mapping between your data and theirs, but it can't tell you what the customer actually meant by a field. Getting that agreed is still a conversation with the customer.
Set up your coding agent (plugin, CLI and the coho prompt reference) →
Related
Keeping two systems in agreement with queues, stored state and a nightly reconciliation job.
When customers want events pushed to their own endpoints, with signing, retries and delivery logs.
Cron that runs beside your data, for exports and reports on a fixed schedule.
API tokens, read-only tokens and JWT login with any JWKS provider.
Keep customer-specific work out of your core product
Each integration, report or custom API gets its own deploy, data and credentials, and your product stays the same for everyone.
A separate space per customer · Data stored in the EU