Determine Income Type

Using our Income API, you can automatically determine the type of income your users are earning.

1: Create A User

To create a new User call the POST /users API endpoint. You can also follow the Getting Started guide to create a User.

2: Create an Income

Next, add a new income by calling the POST /users/{userId}/incomes API endpoint. When creating the income, you must include a description to return an incomeType prediction. Our system will use this description for predicting the incomeType.

curl \
  --request POST \
  --url https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes \
  --header 'Authorization: Bearer <<apiKey>>' \
  --header 'Content-Type: application/json' \
  --data '{
    "incomes": [
      {
        "amount": 222.34,
        "date": "2020-01-14",
        "description": "Client Invoice",
        "category": "Design Services",
        "foreignId": "your_foreign_id",
        "notes": {}
      }
    ]
  }'
const { default: Abound, Environment } = require("@withabound/node-sdk");

const abound = new Abound({
  appId: "<<sandbox_app_id>>",
  appSecret: "<<sandbox_app_secret>>",
  environment: Environment.SANDBOX,
  apiVersion: "v2",
});

(async () => {
  const response = await abound.incomes.create(
    "<<testUserId>>",
    [
      {
        amount: 222.34,
        date: "2020-01-14",
        description: "Client Invoice",
        category: "Design Services",
        foreignId: "your_foreign_id",
        notes: {},
      },
    ]
  );

  console.log(response);
})();
import requests

url = "https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes"

payload = {"incomes": [
        {
            "amount": 222.34,
            "date": "2020-01-14",
            "description": "Client Invoice",
            "category": "Design Services",
            "foreignId": "your_foreign_id",
            "notes": {}
        }
    ]}
headers = {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": "Bearer <<apiKey>>"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
// import com.squareup.okhttp.*;
// import com.google.gson.JsonObject;
// import com.google.gson.JsonArray;
// import com.withabound.AboundConfig;
// import com.withabound.models.*;
// import com.withabound.resources.base*;

AboundConfig aboundConfig = new AboundConfig(
  "<<sandbox_app_id>>",
  "<<sandbox_app_secret>>",
  AboundEnvironment.SANDBOX,
  AboundApiVersion.V2
);
Abound abound = new Abound(aboundConfig);
String userId = "<<testUserId>>";

IncomeRequest incomeRequest = IncomeRequest.builder()
  .incomeType(IncomeType.TEN99)
  .description("Client Invoice")
  .category("Design Services")
  .amount(222.34)
  .date("2020-01-14")
  .foreginId("your_foreign_id")
  .build();

AboundBulkResponse<Income> response = abound.incomes().create(userId, Collections.singletonList(incomeRequest));

System.out.println(response.getData()); // list of created Incomes
package main

import (
    "bytes"
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes"

    var requestBody = []byte(`{
        "incomes": [
            {
                "amount": 222.34,
                "date": "2020-01-14",
                "description": "Client Invoice",
                "category": "Design Services",
                "foreignId": "your_foreign_id",
                "notes": {}
            }
        ]
    }`)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))

    req.Header.Add("Accept", "application/json")
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer <<apiKey>>")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
// using RestSharp;

var client = new RestClient("https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer <<apiKey>>");
request.AddJsonBody(new {
  incomes = new[] {
    new {
      amount = 222.34,
      date = "2020-01-14",
      description = "Client Invoice",
      category = "Design Services",
      foreignId = "your_foreign_id",
      notes = new {}
    }
  }
});
IRestResponse response = client.Execute(request);
require 'uri'
require 'net/http'
require 'openssl'
require 'json'

url = URI("https://sandbox-api.withabound.com/v2/users/<<testUserId>>/incomes")
requestBody = {
  incomes: [
    {
      amount: 222.34,
      date: '2020-01-14',
      description: 'Client Invoice',
      category: 'Design Services',
      foreignId: 'your_foreign_id',
      notes: {}
    }
  ]
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Bearer <<apiKey>>'
request.body = requestBody.to_json

response = http.request(request)
puts response.read_body
{
  "data": [
    {
      "incomeId": "incomeId_test8cb0d56b942722b6d719fa5aa9c5a8dbaa0f",
      "incomeType": "1099",
      "amount": 222.34,
      "description": "Client Invoice",
      "date": "2020-01-14",
      "category": "Design Services",
      "notes": {},
      "foreignId": "your_foreign_id",
      "predictions": {
        "incomeTypePredictionScores": {
          "1099": 0.95701,
          "personal": 0.04299,
          "w2": 0
        }
      }
    }
  ],
  "request": {
    "timestamp": 1629924095695,
    "requestId": "requestId_ba1b709c12dd9c62f532dafa"
  }
}

Did this page help you?