Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Custom API settings

The Basic Info tab of a custom API is a TypeScript object : where the API answers, who may call it, and how it behaves.

Page API Info → Custom API → the API → Basic Info.
Type T.ICustomApiSettingsTypes
URL /api/custom-api/<user path><path> with requestMethod. Path and method together are unique.
Basic Info
import * as T from 'types';
import { EType } from 'types';

let customApi: T.ICustomApiSettingsTypes = {
    name: 'Create Customer',                 // unique ; the folder in Git
    requestMethod: T.ERequestMethod.POST,
    path: '/customers',
    enableCaching: false,
    resetCacheOnModificationOf: [
        // 'DB:mongodb:shop:customers',        // a write to this table resets the cache of this API
        // 'CA:other_custom_api',              // a call of that custom API resets it
    ],
    acceptOnlyEncryptedData: false,
    // customApiTimeoutInSeconds: 10,
    errorList: [ 'Unable to process this request' ],   // translatable in i18n
    apiAccessType: T.EAPIAccessType.TOKEN_ACCESS,
    // authProviders: ['users_tg'],
    reqBodySchema: {
        first_name: { __type: EType.string, validations: { required: true } },
        phone: { __type: EType.number, validations: { min: 5 } },
    },
    fileUpload: { enable: false, allowFileUploadFields: [ T.EFilesVariables.files ], validations: {} },
};
module.exports = customApi;

The keys

Key Meaning
name Unique name, also the folder of the API in Git.
path, requestMethod Where it answers : GET, POST, PUT or DELETE. /customers/:id gives g.req.params.id.
apiAccessType TOKEN_ACCESS (default), IS_PUBLIC, or NO_ACCESS for an API only your code calls.
authProviders The person tokens the call must carry. Absent : common.authProviders of the secret ; [] : the API user token alone.
enableCaching Cache the answer in Redis per body, query and person.
resetCacheOnModificationOf DB:instance:database:table, CA:custom API name, TP:bundle:version : what drops the cached answers. Otherwise reset custom API cache.
acceptOnlyEncryptedData Refuse plain payloads : encrypted payloads.
reqBodySchema, reqQueryParametersSchema A schema for the body and the query : validated and converted before the code runs, checkable with is valid data for custom API.
customApiTimeoutInSeconds How long the code may run.
runOnNativeProcess Run on the process of API Maker instead of the sandbox : faster, less isolated ; console.log is not captured, use g.logger.
errorList The messages this API throws, listed for internationalization.
fileUpload enable, allowFileUploadFields (files…), and per field validations : minFileSizeBytes, maxFileSizeBytes, allowedExtensionsArr. See files.
swaggerDocs tag, summary, description, parameters for the Swagger docs of the API users.