list_licitacao_arquivos
List all files attached to a Brazilian public procurement (licitação) on PNCP, including PDFs, attachments, and terms of reference, returning metadata and direct URLs without downloading content.
Instructions
List the files (edital PDFs, attachments, terms of reference) attached to a licitação on PNCP. Returns metadata and direct URLs — does not download the file content.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| numeroControlePNCP | No | ||
| orgaoCnpj | No | ||
| ano | No | ||
| sequencial | No |
Implementation Reference
- src/schemas/pncp.ts:129-143 (schema)ArquivoSchema: Zod schema defining the shape of each file/attachment returned by the API.
export const ArquivoSchema = z .object({ sequencialDocumento: z.number(), titulo: z.string().nullable().optional(), tipoDocumentoNome: z.string().nullable().optional(), url: z.string().nullable().optional(), uri: z.string().nullable().optional(), dataPublicacaoPncp: z.string().nullable().optional(), cnpj: z.string().nullable().optional(), anoCompra: z.number().nullable().optional(), sequencialCompra: z.number().nullable().optional(), }) .passthrough(); export type Arquivo = z.infer<typeof ArquivoSchema>; - src/adapters/pncp.ts:254-278 (helper)listContratacaoArquivos adapter function that calls the PNCP API endpoint /orgaos/{cnpj}/compras/{ano}/{sequencial}/arquivos and returns parsed Arquivo objects.
export async function listContratacaoArquivos( orgaoCnpj: string, ano: number, sequencial: number, ): Promise<Arquivo[]> { const cacheKey = `list:arquivos:${orgaoCnpj}:${ano}:${sequencial}`; const cached = cache.get<Arquivo[]>(cacheKey); if (cached) return cached; try { const { data } = await withRetry(() => pncpClient.get(`/orgaos/${orgaoCnpj}/compras/${ano}/${sequencial}/arquivos`), ); const arr = asArray(data); const parsed = ArquivoSchema.array().parse(arr); cache.set(cacheKey, parsed, TTL_30_MIN); return parsed; } catch (err) { if (err instanceof AxiosError) { if (err.response?.status === 404) return []; throw new PncpError(describeAxiosError(err), err); } throw err; } }