Let's say you're writing a story about magic. Does it have to be based on real facts and real magic or can you just make up everything and it doesn't have to be based on real facts?
It is probably impossible to fact-check magic because, at least for most of us, magic is not real. You could study existing fictional or mythological systems of magic, but the "facts" you find about those creations will have no more real-world substance than anything you might create yourself.
So unlike many subjects in creative writing, magic does not require a great deal of research and fact-checking. But in the place of those tedious tasks, it offers an even more difficult challenge.
Magic must make sense in the world you are creating.
Whatever rules it operates under, have to be consistent and binding throughout the entire story as well as across all sequels and offshoots. If it is nearly impossible to cast a particular spell during the low-threat early chapters of your tale, it cannot "magically" become easier when later your hero needs to successfully cast it or die. There needs to be a reason why your hero can now do what he previously couldn't. Without such reasons, your magic system is just an excuse for lazy writing.
In addition to making sense, your magic will need to fit your world. You have to be careful not to accidentally make your magic users overwhelmingly powerful. If an average mage can throw a fireball with devastating range and effect, then why do non-magic-users even train for combat. A battalion of skilled swordsmen couldn't stand in a fair fight against a single fire mage. They would never get within sword range.
So, in summary, does the magic in your creative works have to obey the rules established in other fictional and mythological works? No. ...but it still has to obey its own rules and the rules of good writing.
- Keep Writing!
Research is an essential part in the path of an author. Be it fictional or non-fictional writing.
In fictional writing, you can't do "Das Rad neu erfinden" (german for "Reinventing the wheel"). It means: You can't always create new stuff about things, that already exists. So in that case, you have to research. If you want to create a magic System, it is clear, that you have to research real magic. Try to get a grasp for the laws of the magic, think about what suits your story the most, combine things. But the most important part of work in that case is: Research.
The same case is with fictional creatures. I spent a whole month just researching mythical and fantasy creatures, just to write one character. For people, that (roughly said) live in fantasy books and worlds, it feels more authentic and comfortable, if you researched your topic and based even little changes on your research. Heck, for one draft I even researched gods and their powers, family ties, and so on.
You see, even for fictional writers, research is a basic part of their work. Without it, it would also be a bit boring.
You can make up absolutely anything you want.
If you have a need to subvert the laws of nature, time, space and anything else you can think of - you can do this. No-one can prevent you from making up your own system of magic from scratch. Nothing that you write needs to conform to any existing system, whether it be factual or fictional.
When you start a story you have a blank cheque, a tabula rasa, a blank cheque, carte blanche and unlimited discretionary power to act on any and all of those things.
It might be wise to make the systems within your story self-consistent - just to avoid confusing your readers too much, but that doesn't mean that they have to fit in with anything else currently in existence.
Just a quick word of warning: practically, this might not be the easiest thing to do.
Your question can be read in two ways: are you talking of stage magic, or of a fantasy world with actual working magic?
If you are writing about stage magic, you should very definitely do your research: existing stage tricks and how they're done, industry practices, etc. This isn't to say that you cannot make up your own tricks, or suggest something impressive being done on stage without explaining how it's actually done. But you wouldn't want to invent a convoluted explanation for a trick that's actually very simple, for example, right? And you wouldn't want to unknowingly write about practices that the industry would consider unethical as if they're the norm. Research provides you a foundation, on top of which you build your story. Research isn't meant to limit you - there's no reason why you shouldn't invent your own whatever. But research helps you avoid mistakes, as well as sending your imagination into new directions.
If, on the other hand, you are writing about a fantasy world with functioning magic, the magic system itself is your playground, as other answers point out. You can base it on some existing folklore, or you can make it up from scratch. You can give plenty of details about it, or very little - whatever better suits your story. However, there would be other aspects of the story you'd probably need to research. Are you planning a big war between Good and Evil? You'd need to find out about warfare. Would your characters be dealing with hostile terrain? You'd want to find out about survival in those conditions. Etc.
It depends on how closely you want to adhere to a real-world setting.
One of the reasons to adhere closely to a real-world setting is to have the users leverage their understanding of how the world works when trying to comprehend your novel.
Beyond a certain point though, that might not help. For instance in The Romance of the Three Kingdoms (one of the classics of Ancient Chinese literature), all the characters have multiple different names, which makes it hard to track who is doing what to whom.
With my own (Bronze Age + Magic) novellas which started out in Egypt, we have the Pharaohs who all have half a dozen or so names, including a throne name... check out for instance this from the wikipedia article on Amenemhat #3.
Royal titulary Prenomen (Praenomen) Nimaatre Nj-mˁ3t-Rˁ He who belongs to the Maat of Ra
Nomen Amenemhat Jmn-m-ḥ3.t Amun is in front
Horus name Aabaw ˁ3-b3w Great of Bas
Nebty name Itjijautawy Jṯj-j3wt-t3.wj He who inherited the two lands
Golden Horus Wahankh W3ḥ-ˁnḫ Enduring of life
Okay so distinguish between him and his son Amenemhat #4 I called the son Amenemhat and the father by his throne name or Nimaatre.
But it gets worse - because the Egyptians only had three vowels, and ddnt bthr wrtng dwn th vwls whn thy wr wrtng.
So for modern usage we tend to insert 'e' where we think they had a vowel but we're not sure what that was.
So a more famous (in modern times anyway) Pharaoh: Rameses. We're pretty sure about the Ramss bit, and the e's aren't even guesswork, they're just placeholders.
So Amenemhat - or Amnmht, the second is more 'authentic' but much harder to read.
Likewise at that point in the Bronze Age some things we pretty much take for granted on a daily basis such as coinage and boots hadn't been invented yet.
Never mind that most lay-people if asked would say that they thought the Egyptians invented chariots, but chariots were actually an imported technology.
So I could play to the stereotypes, or I could strive for a bit more historical accuracy.
One of the things that I found out afterwards was that all the research I had done was actually valuable. More so (perhaps) than my writing. Because in an educational environment - even if it's just hundreds of links to external sources - you can leverage that.
Think about it as perhaps the e-book equivalent of DVD extras.
I'd also suggest playing to your strengths (and more importantly your weaknesses). I have a bit of an idiosyncratic style - which is always going to be harder to read than someone who has done ten years of journalism where they're writing to a fifth grade or lower level of reading and had that beaten into them by a sequence of editors over the years.
Because of that I need to try to not impose additional cognitive burdens on the readers.
As for the world-building aspects of magic ... you can try to have a Sandersonian approach where you try to figure out all the scientific underpinnings and rules and meta-rules whereby your magic operates, and then adhere to them dogmatically. Otherwise you are sort of forced into a 'going to mage-school' pattern where you have to explain the magic through the eyes of someone learning it.
Otherwise your reader has no firm anchor when it comes to the magic. And that can be potentially unsatisfying. Oh look, he got to the final confrontation with the Dark Overlord of the Universe and all along he's been frabjulating the mictation, just like every other magic user, but now when the chips are down he's mictating the frabjulation!!! Madness!!! Oh wait it worked.
Of course that can work - e.g. in Ghostbusters where they cross the streams and blow up the marshmellow man. But if you do that you run the risk of that pattern being recognised, or just called out as a Deus Ex Machina. (See also: time turner).
If you are just winging it, as far as your setting and magic system goes, I think it helps to be consistent - or if not that (e.g. your main character has a subset of the rules explained to them) - then let it be the bad guys who break the established rules first (and most often), and do so to gain an advantage over your hero(es). Among other things, it makes them look scary and dangerous and smart, because they figured out something nobody else did, and it gave them a big advantage.
It all depends of your goals and the targeted readers.
If you want something realist and avoid naive approaches, you must study a lot your subject, specially if you expect that your readers already know something about it. Even if you have deeply studied, expect some experts to point how newbie you are. If you target a wide audience, there will be experts doing so... or jerks thinking that they are experts.
You also may want to follow a naive approach. This may be motivated by the style of your narration, the ambience of your story. This can be poetic in a way. Or just what you need for kids. But, even in this case, you cannot avoid at least a little study of the subject if you don't want to make a fool of yourself.
Regarding, magic, both approaches may work. It all depends of your story. You may have a look in old cryptic memoirs, or learn about the Kabale. Read the Papyrus of Ani, and so on if you want your story to plunge its roots in reality. You may study the history of illusionism, and play on some ambiguities with Magic, real or fake.
If you want to write fantasy, you may avoid studies, but expects some experts to compare with already written magic systems, and finding that your work is not so original - and depreciate it for that.
Make up anything you like (without violating copyrights and trademarks).
Outside of intellectual property laws, the whole point of fiction is to exercise your imagination.
That said, if you write for readers (not just yourself and your own entertainment), then they will expect certain things to be true about your story; and if they don't like it, they just won't buy it.
Much of this site is devoted to these unwritten expectations of readers and what turns them off or makes them stop reading or feel like they have wasted their money, or even actively insult and denigrate an author's work as both revenge and a public service.
Specifically the reader's representatives, in the terms of agents, publishers and professional critics: They have spent a career learning what readers will want to read, so unless you self-publish, you must pass those gatekeepers: Get an agent that likes your work for its saleability, so she can sell it to a publisher and make some bucks for both of you; and both agent and publisher will have in mind what critics might say about it.
I won't go into all the details, but readers do expect reasonable consistency of magic systems, characters, and the setting. Although you can just make all of these up (and I do), it might be difficult to sustain this sense of consistency if you don't do any planning or research at all. If your setting is medieval, you break consistency if your characters find magic iPhones or flying saucers they can pilot, or suddenly discover halfway through the story they have telepathy, because that was convenient for your plot.
But the answer is yes, you definitely can just make it up from scratch as you go along, and don't feel bad about it; I do it. I usually make several passes through my finished story to ensure consistency, and often will draw a map of my world as I go along and need new places.
I'm a discovery writer, and I've taught myself tricks to be successful that way. Perhaps you are too --- Making it up as we go along is how we work.
Yes, absolutely, but it may not be in the traditional sense of the word.
For everything outside of a magic system, research is required to ensure that, at the very minimum, the story does not require too much suspension of disbelief. The elements need to make sense even (or especially) in a fantasy setting, otherwise it throws the reader out of the story and they will not get back into it. You don't need to become an expert, but at the very least, a general understanding of how things work is required for the story to be immersive, and, for you to be able to justify why something behaves as it does.
As a writer, you need to be able to demonstrate consistency and explain why things aren't as expected
This is doubly true for magic systems you create. Obviously, research on magic is limited to existing systems created by others. You want something different? Brilliant! However, the research comes into by you not just making it up as you go along. The research is required to ensure you are being internally consistent, and this consistency is the key to creating a magic system. Even for discovery writers, consistency is required and you need to have an understanding of what you are writing. You can't start a story off with one type of magic only being able to be used by those of royal blood, only to have every man and their dog using it halfway through the second book for no other reason than you forgot what you had created.
So the research required for your own magic system isn't externally focused, it's about ensuring you have established consistency and understand what you are creating.