{"info":{"title":"GovSpend API docs","description":"**Welcome to the GovSpend API docs!**<br /><br />\n        The available services and their supported methods are listed below.\n        You will need to obtain an API key <a href=\"https://app.govspend.com/account/apiKeys\">here</a> in order to use this API.<br /><br />\n        All requests should contain the header: `X-API-KEY [your API key]` and\n        should be prefixed with `https://api.govspend.com`<br /><br />\n        To try out the API, click on the **Authorize** button and enter your **API Key**.<br /><br />\n        If you have any questions or feedback please contact customer support.","version":"1.1.0"},"components":{"securitySchemes":{"APIKey":{"in":"header","type":"apiKey","name":"X-API-KEY"}},"schemas":{}},"paths":{"/exportCreditStats":{"get":{"parameters":[{"name":"searchId","description":"The id of the saved search to get the result count. Leave blank to get the actual remaining export credits for the user account.","schema":{"type":"string"},"in":"query"}],"responses":{"200":{"description":"Success!","content":{"application/json":{"schema":{"type":"object"},"example":{"hasSufficientCredits":true,"bulkCredits":0,"monthlyCredits":0,"monthlyAvailable":0,"bulkAvailable":0,"totalAvailable":0,"totalRecords":0}}}}},"description":"Returns the remaining export credits for the authorized user account.<br />        The user is extracted from the authorization scheme used.<br />        When provided with a **searchId** query parameter it returns the number of results (**totalRecords** property) for that saved search **without using export credits**.","summary":"","tags":["Public"],"security":[{"APIKey":[]}]}},"/runSavedSearch":{"post":{"parameters":[],"responses":{"200":{"description":"Success!","content":{"application/json":{"schema":{"type":"object"},"example":{"page":1,"pageSize":100,"totalPages":1,"totalRecords":5,"exportCreditsUsed":5,"savedSearchType":"Spending","result":["Results go here ..."]}}}}},"description":"Executes a saved search by **id** and returns the results. **Consumes an export credit per each record returned**.<br />       To get the **id** of a saved search use the **savedSearch** service (which returns a list of your saved searches and their ids).<br />       To view how much credits will a saved search consume refer to the **exportCreditStats** service.","summary":"","tags":["Public"],"security":[{"APIKey":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object"},"example":{"id":"saved search id goes here","page":1,"include":[],"sort":[{"field":"sort field goes here","desc":true}]}}}}}},"/savedSearch":{"get":{"parameters":[{"description":"Number of results to return","in":"query","name":"$limit","schema":{"type":"integer"}},{"description":"Number of results to skip","in":"query","name":"$skip","schema":{"type":"integer"}},{"description":"Property to sort results","in":"query","name":"$sort","style":"deepObject","schema":{"type":"object"}}],"responses":{"200":{"description":"Success!","content":{"application/json":{"schema":{"type":"object"},"example":{"total":2,"limit":50,"skip":0,"data":[{"_id":"5efgebf5866e1e002d831a12","name":"Search I"},{"_id":"5eklebf5866e1e002d831a87","name":"Search II"}]}}}}},"description":"Returns the list of saved searches for a specific user.<br />        Each result contains the **name** and the **id (as _id)** of a saved search.<br />        The user is extracted from the authorization scheme used.","summary":"","tags":["Public"],"security":[{"APIKey":[]}]}},"/spendingAggregation":{"get":{"parameters":[{"in":"query","name":"groupBy","required":false,"description":"Grouping type. Defaults to `agency`.","schema":{"type":"string","enum":["agency","vendor"]}},{"in":"query","name":"months","required":false,"description":"How many months to include in the aggregation window (for example `12` for last 12 months). Defaults to `60`.","schema":{"type":"integer","minimum":1}},{"in":"query","name":"limit","required":false,"description":"How many grouped results to return (top results by spend). Defaults to `1000`; maximum is `20000`.","schema":{"type":"integer","minimum":1,"maximum":20000,"default":1000}},{"in":"query","name":"id","required":false,"description":"Optional ID filter. Accepts a single numeric value, repeated query values, or a comma-delimited list. Uses agency ID when `groupBy=agency` and vendor ID when `groupBy=vendor`.","schema":{"oneOf":[{"type":"integer"},{"type":"array","items":{"type":"integer"}}]}},{"in":"query","name":"sortDir","required":false,"description":"Sort direction for total spend. Defaults to `desc` (highest spend first).","schema":{"type":"string","enum":["asc","desc"]}}],"responses":{"200":{"description":"Success!","content":{"application/json":{"schema":{"type":"object"},"example":{"groupBy":"agency","sortDir":"desc","timeframe":{"months":12,"from":"2025-03-01T00:00:00.000Z","to":"2026-02-28T23:59:59.999Z"},"data":[{"id":12345,"name":"City of Austin, TX","totalSpend":48392012.11,"totalLineItems":10491}]}}}}},"description":"Returns total spend grouped by agency or vendor for a month-based timeframe. Results are ordered by total spend. Values are intended for reporting and may vary slightly from exact totals.","summary":"","tags":["Public"],"security":[{"APIKey":[]}]}},"/token":{"post":{"parameters":[],"responses":{"200":{"description":"JWT for the given user with the scoped email address.","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"}}},"example":{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6ImFjY2VzcyJ9.eyJzdWIiOiI2MTJlMjkxZjRhMGY2OTQxZGFlZGU2MzYiLCJhdWQiOiI1ZjdjN2Q4NDMxZjQ3OTUzZDQ1YWM4MGEiLCJpYXQiOjE2MzA2MTczNDYsImV4cCI6MTYzMDYzODk0NiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDoxMzM3IiwianRpIjoiOTgzMTI3MTktZWMxZS00YzNmLTgzOGUtNWJiZDE0N2NmZjFmIn0.cEBMbTm1n2N4fFc3a_wZVDBEhdJSaePio9I8n1lfl7U"}}}},"401":{"description":"Invalid API key"},"403":{"description":"User does not have the `manageOrganization` permission"},"404":{"description":"Email address not found"}},"description":"Retrieve an access token for a given user within your organization.\n      The user making the request must have the `manageOrganization` permission.\n      Once you have an access token you can redirect the user to `https://app.govspend.com/#access_token=[access token]`","summary":"","tags":["Public"],"security":[{"APIKey":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"scope":{"type":"string"}}},"example":{"scope":"joe@myorganization.com"}}}}}}},"openapi":"3.0.2","tags":[]}