Create a database programmatically through the SDK/API

I can see that I can easily create tables, etc., on the website “by hand”, but this is not safe or reliable compared to programmatic techniques. It is also not managed well over time. I would like to connect to 8base from C# Visual Studio and generate my database from my model classes there. Is this supported?

Hey @marcusts - you can do this. However, it needs to be done using an existing workspace’s API. This might feel counterintuitive, but it is how it currently works.

So, you must manually create your first workspace (it can be on any plan, including free). You can then make requests to that workspaces API Endpoint, like so:

mutation {
  workspaceCreate(data: {
    name: "My New Workspace"
    kind: general
    billingPlanId: "PLAN_ID"
  }) {
    id
  }
} 

This will create a new workspace (including a database) that you can then interact with programmatically. The language/environment from which you are sending these API requests doesn’t matter, so C# from VS is fine.

Thank you for responding. Are there any C# examples for creating tables, etc., through the API?

We don’t have any C# examples. However, here’s a GraphQL Client for .NET https://github.com/graphql-dotnet/graphql-client and it would be the same mutation as in any other language:

var createTableRequest = new GraphQLRequest {
    Query =@"
    mutation ($data: TableCreateInput!) {
        tableCreate(data: $data) {
            createdAt
        }
    }",
    Variables = new {
        data = {...DATA_OBJECT}
    }
};