Exposing CICS and IMS programs as APIs
You do not rewrite a working CICS or IMS program to give it an API. A gateway on z/OS receives the HTTP request, converts the JSON into the program's input structure, calls the program, and converts the result back.
The request's journey
z/OS Connect
IBM z/OS Connect is the most common way to do this. You describe the API in an OpenAPI document, map each request and response field to the copybook, and z/OS Connect calls the program through CICS, IMS, MQ or DB2. The COBOL program still receives a COMMAREA or a channel and containers exactly as before.
- One API, many programs.
GET /accounts/{id}might call ACCTINQ, whilePOST /paymentscalls PAYPOST. - Path and query values such as
{id}are mapped into input fields. - Program results become HTTP status codes — for example, a not-found flag in the output becomes 404.
Other routes
- CICS web support lets a CICS program handle HTTP requests itself, with the CICS JSON assistant generating the conversion. More control, more code.
- DB2 REST services expose a single SQL statement or stored procedure as a REST endpoint, useful for simple reads.
- MQ is common when the caller should not wait: the request is put on a queue and processed asynchronously.
$ curl -H "Authorization: Bearer eyJhbGciOi..." \ https://api.examplebank.com/accounts/00412789 HTTP/1.1 200 OK { "accountId": "00412789", "name": "Asha Rao", "balance": 1520.75 }
Common mistakes
Mirroring every existing transaction as its own API exposes internal design. Design APIs around business actions, such as 'get account summary', and map them to programs.
A COMMAREA holds at most 32 KB. Large responses need channels and containers, or paging.
If processing takes minutes, the HTTP call times out. Use MQ or an asynchronous pattern and let the caller check back.
What you will see at work
- Mainframe developers usually own the mapping and the program changes; API platform teams own the gateway and its policies.
- Performance testing matters: a popular app can send far more requests than a branch network ever did.
- Existing screen-based transactions often mix presentation and logic. Separating them is a common first step before exposing an API.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.