{"record":{"id":"44e937c912423725","repo":"crowdsecurity/crowdsec","slug":"no-api-client-section-in-configuration","errorCode":null,"errorMessage":"no API client section in configuration","messagePattern":"no API client section in configuration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/api.go","lineNumber":514,"sourceCode":"\n\tfd, err := os.Open(c.CapiWhitelistsPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while opening capi whitelist file: %w\", err)\n\t}\n\n\tdefer fd.Close()\n\n\tc.CapiWhitelists, err = parseCapiWhitelists(fd)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"while parsing capi whitelist file '%s': %w\", c.CapiWhitelistsPath, err)\n\t}\n\n\treturn nil\n}\n\nfunc (c *Config) LoadAPIClient() error {\n\tif c.API == nil || c.API.Client == nil || c.API.Client.CredentialsFilePath == \"\" || c.DisableAgent {\n\t\treturn errors.New(\"no API client section in configuration\")\n\t}\n\n\treturn c.API.Client.Load()\n}\n\nfunc (c *LocalApiServerCfg) LoadAutoRegister() error {\n\tif c.AutoRegister == nil {\n\t\tc.AutoRegister = &LocalAPIAutoRegisterCfg{\n\t\t\tEnable: new(false),\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Disable by default\n\tif c.AutoRegister.Enable == nil {\n\t\tc.AutoRegister.Enable = new(false)\n\t}","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/api.go#L496-L532","documentation":"LoadAPIClient loads the LAPI client credentials for the crowdsec agent. It requires the api section, api.client section, and a credentials file path to exist, and that the agent is not disabled; otherwise it reports that no API client section is present. This distinguishes 'agent cannot talk to LAPI' misconfigurations from valid no-API setups.","triggerScenarios":"Running crowdsec in agent mode when config.yaml lacks api.client, or lacks api entirely, or api.client.credentials has no credentials_file, or api.client is disabled via disable_agent; LoadCrowdsec -> LoadAPIClient path.","commonSituations":"A parser-only/standalone crowdsec install where the api section was removed; a mis-indented yaml that swallows the client block into another key; fresh installs whose default config was replaced by a minimal one.","solutions":["Add the api.client section with credentials_file pointing to the local credentials yaml","Run 'cscli lapi register' to generate the credentials file, then re-check indentation","If no LAPI connection is desired, ensure the agent is intentionally configured as standalone and this error is expected"],"exampleFix":"# before: no api.client in config.yaml\n# after\napi:\n  client:\n    insecure_skip_verify: false\n    credentials_file: /etc/crowdsec/local_api_credentials.yaml","handlingStrategy":"try-catch","validationCode":"if cfg.API == nil || cfg.API.Client == nil || cfg.API.Client.CredentialsFilePath == \"\" {\n    // run standalone or register first: cscli lapi register\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadAPIClient(); err != nil {\n    return fmt.Errorf(\"lapi client: %w\", err)\n}","preventionTips":["Run 'cscli lapi register' on agent hosts so the credentials file and api.client section exist","Keep the default config.yaml api.client block intact when trimming configs","Verify yaml indentation so api.client is not nested under the wrong key"],"tags":["go","config","lapi","crowdsec-agent"],"backgroundTag":"missing-required-config","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}